OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include <webrtc/rtc_base/task_queue_impl_factory.h> | |
12 | |
13 namespace rtc { | |
14 | |
15 // TODO(perkj): now!! Do we have a way to lazy instantiate ? OnceInit... | |
16 static TaskQueueImplFactory* taskqueue_factory = nullptr; | |
17 static rtc::CriticalSection set_lock; | |
18 | |
19 // Sets the factory to be used by this process. May only be called once | |
20 // before any TaskQueues are created. | |
21 // static | |
22 void TaskQueueImplFactory::Set(TaskQueueImplFactory* factory) { | |
kwiberg-webrtc
2017/08/21 09:21:55
Is it really a good idea for Set() to not take own
| |
23 rtc::CritScope lock(&set_lock); | |
24 // TODO(perkj): if OnceInit exist... DOn't allow someone to call Set again. | |
nisse-webrtc
2017/08/18 11:45:45
If you can put a static variable in a single metho
| |
25 if (taskqueue_factory) | |
26 return; | |
kwiberg-webrtc
2017/08/21 09:21:55
If the contract is that you're only allowed to cal
| |
27 taskqueue_factory = factory; | |
28 } | |
29 | |
30 TaskQueueImplFactory* TaskQueueImplFactory::Get() { | |
31 if (taskqueue_factory) | |
kwiberg-webrtc
2017/08/21 09:21:55
Don't read this variable without taking the lock.
| |
32 return taskqueue_factory; | |
33 #if defined(WEBRTC_LINUX) | |
34 Set(new TaskQueueLibEventFactory()); | |
35 #endif | |
36 return taskqueue_factory; | |
37 } | |
38 | |
39 } // namespace rtc | |
OLD | NEW |