Lines Matching full:thread

11 #include "rtc_base/thread.h"
67 Thread* post_thread, in SocketClient()
94 Thread* post_thread_;
101 MessageClient(Thread* pth, Socket* socket) : socket_(socket) {} in MessageClient()
116 class CustomThread : public rtc::Thread {
119 : Thread(std::unique_ptr<SocketServer>(new rtc::NullSocketServer())) {} in CustomThread()
123 bool WrapCurrent() { return Thread::WrapCurrent(); } in WrapCurrent()
124 void UnwrapCurrent() { Thread::UnwrapCurrent(); } in UnwrapCurrent()
127 // A thread that does nothing when it runs and signals an event
129 class SignalWhenDestroyedThread : public Thread {
132 : Thread(std::unique_ptr<SocketServer>(new NullSocketServer())), in SignalWhenDestroyedThread()
180 // Function objects to test Thread::Invoke.
197 Thread::Current()->ProcessMessages(50); in operator ()()
220 // Create the messaging client on its own thread. in TEST()
221 auto th1 = Thread::CreateWithSocketServer(); in TEST()
226 // Create the socket client on its own thread. in TEST()
227 auto th2 = Thread::CreateWithSocketServer(); in TEST()
242 Thread* th_main = Thread::Current(); in TEST()
258 // Test that setting thread names doesn't cause a malfunction.
262 auto thread = Thread::CreateWithSocketServer(); in TEST() local
263 EXPECT_TRUE(thread->Start()); in TEST()
264 thread->Stop(); in TEST()
266 thread = Thread::CreateWithSocketServer(); in TEST()
267 EXPECT_TRUE(thread->SetName("No object", nullptr)); in TEST()
268 EXPECT_TRUE(thread->Start()); in TEST()
269 thread->Stop(); in TEST()
271 thread = Thread::CreateWithSocketServer(); in TEST()
272 EXPECT_TRUE(thread->SetName("Abcdefghijklmnopqrstuvwxyz1234567890", this)); in TEST()
273 EXPECT_TRUE(thread->Start()); in TEST()
274 thread->Stop(); in TEST()
278 Thread* current_thread = Thread::Current(); in TEST()
284 EXPECT_EQ(&cthread, Thread::Current()); in TEST()
295 // Create and start the thread. in TEST()
296 auto thread1 = Thread::CreateWithSocketServer(); in TEST()
297 auto thread2 = Thread::CreateWithSocketServer(); in TEST()
301 Thread* th_main = Thread::Current(); in TEST()
306 // Create and start the thread. in TEST()
307 auto thread1 = Thread::CreateWithSocketServer(); in TEST()
308 auto thread2 = Thread::CreateWithSocketServer(); in TEST()
309 auto thread3 = Thread::CreateWithSocketServer(); in TEST()
310 auto thread4 = Thread::CreateWithSocketServer(); in TEST()
320 Thread* th_main = Thread::Current(); in TEST()
325 // Create and start the thread. in TEST()
326 auto thread1 = Thread::CreateWithSocketServer(); in TEST()
327 auto thread2 = Thread::CreateWithSocketServer(); in TEST()
334 Thread* th_main = Thread::Current(); in TEST()
340 // Create and start the thread. in TEST()
341 auto thread1 = Thread::CreateWithSocketServer(); in TEST()
342 auto thread2 = Thread::CreateWithSocketServer(); in TEST()
346 Thread* th_main = Thread::Current(); in TEST()
351 // Create and start the thread. in TEST()
352 auto thread = Thread::CreateWithSocketServer(); in TEST() local
353 thread->Start(); in TEST()
355 EXPECT_EQ(42, thread->Invoke<int>(RTC_FROM_HERE, FunctorA())); in TEST()
358 thread->Invoke<void>(RTC_FROM_HERE, f2); in TEST()
365 EXPECT_EQ(999, thread->Invoke<int>(RTC_FROM_HERE, &LocalFuncs::Func1)); in TEST()
366 thread->Invoke<void>(RTC_FROM_HERE, &LocalFuncs::Func2); in TEST()
374 AutoThread thread; in TEST() local
375 Thread* main_thread = Thread::Current(); in TEST()
376 auto other_thread = Thread::CreateWithSocketServer(); in TEST()
385 AutoThread thread; in TEST() local
386 Thread* first = Thread::Current(); in TEST()
388 auto second = Thread::Create(); in TEST()
390 auto third = Thread::Create(); in TEST()
402 // Verifies that if thread A invokes a call on thread B and thread C is trying
403 // to invoke A at the same time, thread A does not handle C's invoke while
406 AutoThread thread; in TEST() local
407 Thread* thread_a = Thread::Current(); in TEST()
408 auto thread_b = Thread::CreateWithSocketServer(); in TEST()
409 auto thread_c = Thread::CreateWithSocketServer(); in TEST()
434 static void InvokeSet(Thread* thread, LockedBool* out) { in TEST()
435 thread->Invoke<void>(RTC_FROM_HERE, Bind(&Set, out)); in TEST()
438 // Set |out| true and call InvokeSet on |thread|. in TEST()
440 Thread* thread, in TEST()
443 InvokeSet(thread, out_inner); in TEST()
449 Thread* thread1, in TEST()
450 Thread* thread2, in TEST()
466 // Thread B returns when C receives the call and C should be blocked until A in TEST()
476 // Set the name on a thread when the underlying QueueDestroyed signal is
481 SetNameOnSignalQueueDestroyedTester(Thread* thread) : thread_(thread) { in SetNameOnSignalQueueDestroyedTester() argument
482 thread->SignalQueueDestroyed.connect( in SetNameOnSignalQueueDestroyedTester()
487 // Makes sure that if we access the Thread while it's being destroyed, that in OnQueueDestroyed()
493 Thread* thread_;
497 auto thread1 = Thread::CreateWithSocketServer(); in TEST()
501 Thread* thread2 = new AutoThread(); in TEST()
506 class ThreadQueueTest : public ::testing::Test, public Thread {
508 ThreadQueueTest() : Thread(SocketServer::CreateDefault(), true) {} in ThreadQueueTest()
517 // We have to do this on a worker thread, or else the TryEnter will in IsLocked()
519 std::unique_ptr<Thread> worker(Thread::CreateWithSocketServer()); in IsLocked()
538 static void DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(Thread* q) { in DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder()
558 Thread q(SocketServer::CreateDefault(), true); in TEST_F()
562 Thread q_nullss(&nullss, true); in TEST_F()
604 auto a = Thread::CreateWithSocketServer(); in TEST()
605 auto b = Thread::CreateWithSocketServer(); in TEST()
614 // the main thread, which is guaranteed to be handled inside in TEST()
628 rtc::Thread::Current()->PostTask(ToQueuedTask(event_signaler)); in TEST()
634 // Test that ProcessAllMessageQueues doesn't hang if a thread is quitting.
636 auto t = Thread::CreateWithSocketServer(); in TEST()
646 auto t = Thread::CreateWithSocketServer(); in TEST()
652 // main thread, which is guaranteed to be handled inside in TEST()
655 rtc::Thread::Current()->Clear(nullptr); in TEST()
663 rtc::Thread::Current()->PostTask(RTC_FROM_HERE, event_signaler); in TEST()
678 std::unique_ptr<Thread> t(Thread::Create()); in TEST()
687 // message queue of the thread while the outer handler is removed, verifying in TEST()
697 EXPECT_EQ(expected_thread_, Thread::Current()); in IntCallback()
700 void SetExpectedThreadForIntCallback(Thread* thread) { in SetExpectedThreadForIntCallback() argument
701 expected_thread_ = thread; in SetExpectedThreadForIntCallback()
709 Thread* expected_thread_;
714 // Create and start the thread. in TEST_F()
715 auto thread = Thread::CreateWithSocketServer(); in TEST_F() local
716 thread->Start(); in TEST_F()
719 invoker.AsyncInvoke<void>(RTC_FROM_HERE, thread.get(), FunctorB(&called)); in TEST_F()
721 thread->Stop(); in TEST_F()
726 // Create and start the thread. in TEST_F()
727 auto thread = Thread::CreateWithSocketServer(); in TEST_F() local
728 thread->Start(); in TEST_F()
731 invoker.AsyncInvoke<void>(RTC_FROM_HERE, thread.get(), FunctorD(&called)); in TEST_F()
733 thread->Stop(); in TEST_F()
744 auto thread = Thread::CreateWithSocketServer(); in TEST_F() local
745 thread->Start(); in TEST_F()
752 rtc::Thread::Current()->SleepMs(kWaitTimeout); in TEST_F()
757 invoker.AsyncInvoke<void>(RTC_FROM_HERE, thread.get(), functor); in TEST_F()
773 // *again*, for the thread on which the AsyncInvoker is currently being
781 Thread* main = Thread::Current(); in TEST_F()
782 Thread thread(std::make_unique<NullSocketServer>()); in TEST_F() local
783 thread.Start(); in TEST_F()
791 Thread::Current()->SleepMs(kWaitTimeout); in TEST_F()
794 // This queues a task on |thread| to sleep for |kWaitTimeout| then queue a in TEST_F()
797 invoker.AsyncInvoke<void>(RTC_FROM_HERE, &thread, functor); in TEST_F()
807 // Queue two async calls to the current thread. in TEST_F()
808 invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag1)); in TEST_F()
809 invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag2)); in TEST_F()
814 invoker.Flush(Thread::Current()); in TEST_F()
823 // Queue two async calls to the current thread, one with a message id. in TEST_F()
824 invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag1), in TEST_F()
826 invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag2)); in TEST_F()
831 invoker.Flush(Thread::Current(), 5); in TEST_F()
836 invoker.Flush(Thread::Current()); in TEST_F()
841 void ThreadIsCurrent(Thread* thread, bool* result, Event* event) { in ThreadIsCurrent() argument
842 *result = thread->IsCurrent(); in ThreadIsCurrent()
884 // A functor that verifies the thread it was destroyed on.
887 DestructionFunctor(Thread* thread, bool* thread_was_current, Event* event) in DestructionFunctor() argument
888 : thread_(thread), in DestructionFunctor()
904 Thread* thread_;
911 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
920 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
929 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
943 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
957 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
972 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
986 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
1001 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
1016 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
1030 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
1034 // thread. The second event ensures that the message is processed. in TEST()
1045 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
1067 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
1071 // thread. The second event ensures that the message is processed. in TEST()
1085 std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create()); in TEST()
1113 std::unique_ptr<rtc::Thread> thread(rtc::Thread::Create()); in TEST() local
1114 thread->WrapCurrent(); in TEST()
1116 static_cast<webrtc::TaskQueueBase*>(thread.get())); in TEST()
1117 thread->UnwrapCurrent(); in TEST()
1127 std::unique_ptr<Thread> thread = Thread::Create(); in CreateTaskQueue() local
1128 thread->Start(); in CreateTaskQueue()
1130 thread.release()); in CreateTaskQueue()