| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 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/test/channel_transport/udp_socket_manager_wrapper.h" | |
| 12 | |
| 13 #include <assert.h> | |
| 14 | |
| 15 #ifdef _WIN32 | |
| 16 #include "webrtc/system_wrappers/include/fix_interlocked_exchange_pointer_win.h" | |
| 17 #include "webrtc/test/channel_transport/udp_socket2_manager_win.h" | |
| 18 #else | |
| 19 #include "webrtc/test/channel_transport/udp_socket_manager_posix.h" | |
| 20 #endif | |
| 21 | |
| 22 namespace webrtc { | |
| 23 namespace test { | |
| 24 | |
| 25 UdpSocketManager* UdpSocketManager::CreateInstance() | |
| 26 { | |
| 27 #if defined(_WIN32) | |
| 28 return static_cast<UdpSocketManager*>(new UdpSocket2ManagerWindows()); | |
| 29 #else | |
| 30 return new UdpSocketManagerPosix(); | |
| 31 #endif | |
| 32 } | |
| 33 | |
| 34 UdpSocketManager* UdpSocketManager::StaticInstance( | |
| 35 CountOperation count_operation, | |
| 36 const int32_t id, | |
| 37 uint8_t& numOfWorkThreads) | |
| 38 { | |
| 39 UdpSocketManager* impl = | |
| 40 GetStaticInstance<UdpSocketManager>(count_operation); | |
| 41 if (count_operation == kAddRef && impl != NULL) { | |
| 42 if (impl->Init(id, numOfWorkThreads)) { | |
| 43 impl->Start(); | |
| 44 } | |
| 45 } | |
| 46 return impl; | |
| 47 } | |
| 48 | |
| 49 UdpSocketManager* UdpSocketManager::Create(const int32_t id, | |
| 50 uint8_t& numOfWorkThreads) | |
| 51 { | |
| 52 return UdpSocketManager::StaticInstance(kAddRef, id, numOfWorkThreads); | |
| 53 } | |
| 54 | |
| 55 void UdpSocketManager::Return() | |
| 56 { | |
| 57 uint8_t numOfWorkThreads = 0; | |
| 58 UdpSocketManager::StaticInstance(kRelease, -1, | |
| 59 numOfWorkThreads); | |
| 60 } | |
| 61 | |
| 62 UdpSocketManager::UdpSocketManager() : _numOfWorkThreads(0) | |
| 63 { | |
| 64 } | |
| 65 | |
| 66 uint8_t UdpSocketManager::WorkThreads() const | |
| 67 { | |
| 68 return _numOfWorkThreads; | |
| 69 } | |
| 70 | |
| 71 } // namespace test | |
| 72 } // namespace webrtc | |
| OLD | NEW |