Lines Matching full:thread
11 #include "rtc_base/thread.h"
123 void ThreadManager::Add(Thread* message_queue) { in Add()
126 void ThreadManager::AddInternal(Thread* message_queue) { in AddInternal()
134 void ThreadManager::Remove(Thread* message_queue) { in Remove()
137 void ThreadManager::RemoveInternal(Thread* message_queue) { in RemoveInternal()
142 std::vector<Thread*>::iterator iter; in RemoveInternal()
154 void ThreadManager::RemoveFromSendGraph(Thread* thread) { in RemoveFromSendGraph() argument
156 if (it->first == thread) { in RemoveFromSendGraph()
159 it->second.erase(thread); in RemoveFromSendGraph()
165 void ThreadManager::RegisterSendAndCheckForCycles(Thread* source, in RegisterSendAndCheckForCycles()
166 Thread* target) { in RegisterSendAndCheckForCycles()
168 std::deque<Thread*> all_targets({target}); in RegisterSendAndCheckForCycles()
194 for (Thread* queue : message_queues_) { in ClearInternal()
225 for (Thread* queue : message_queues_) { in ProcessAllMessageQueuesInternal()
237 rtc::Thread* current = rtc::Thread::Current(); in ProcessAllMessageQueuesInternal()
238 // Note: One of the message queues may have been on this thread, which is in ProcessAllMessageQueuesInternal()
249 Thread* Thread::Current() { in Current()
251 Thread* thread = manager->CurrentThread(); in Current() local
254 // Only autowrap the thread which instantiated the ThreadManager. in Current()
255 if (!thread && manager->IsMainThread()) { in Current()
256 thread = new Thread(SocketServer::CreateDefault()); in Current()
257 thread->WrapCurrentWithThreadManager(manager, true); in Current()
261 return thread; in Current()
272 Thread* ThreadManager::CurrentThread() { in CurrentThread()
273 return static_cast<Thread*>(pthread_getspecific(key_)); in CurrentThread()
276 void ThreadManager::SetCurrentThreadInternal(Thread* thread) { in SetCurrentThreadInternal() argument
277 pthread_setspecific(key_, thread); in SetCurrentThreadInternal()
285 Thread* ThreadManager::CurrentThread() { in CurrentThread()
286 return static_cast<Thread*>(TlsGetValue(key_)); in CurrentThread()
289 void ThreadManager::SetCurrentThreadInternal(Thread* thread) { in SetCurrentThreadInternal() argument
290 TlsSetValue(key_, thread); in SetCurrentThreadInternal()
294 void ThreadManager::SetCurrentThread(Thread* thread) { in SetCurrentThread() argument
296 if (CurrentThread() && thread) { in SetCurrentThread()
301 if (thread) { in SetCurrentThread()
302 thread->EnsureIsCurrentTaskQueue(); in SetCurrentThread()
304 Thread* current = CurrentThread(); in SetCurrentThread()
306 // The current thread is being cleared, e.g. as a result of in SetCurrentThread()
307 // UnwrapCurrent() being called or when a thread is being stopped in SetCurrentThread()
308 // (see PreRun()). This signals that the Thread instance is being detached in SetCurrentThread()
309 // from the thread, which also means that TaskQueue::Current() must not in SetCurrentThread()
310 // return a pointer to the Thread instance. in SetCurrentThread()
315 SetCurrentThreadInternal(thread); in SetCurrentThread()
318 void rtc::ThreadManager::ChangeCurrentThreadForTest(rtc::Thread* thread) { in ChangeCurrentThreadForTest() argument
319 SetCurrentThreadInternal(thread); in ChangeCurrentThreadForTest()
322 Thread* ThreadManager::WrapCurrentThread() { in WrapCurrentThread()
323 Thread* result = CurrentThread(); in WrapCurrentThread()
325 result = new Thread(SocketServer::CreateDefault()); in WrapCurrentThread()
332 Thread* t = CurrentThread(); in UnwrapCurrentThread()
343 Thread::ScopedDisallowBlockingCalls::ScopedDisallowBlockingCalls() in ScopedDisallowBlockingCalls()
344 : thread_(Thread::Current()), in ScopedDisallowBlockingCalls()
347 Thread::ScopedDisallowBlockingCalls::~ScopedDisallowBlockingCalls() { in ~ScopedDisallowBlockingCalls()
352 Thread::Thread(SocketServer* ss) : Thread(ss, /*do_init=*/true) {} in Thread() function in rtc::Thread
354 Thread::Thread(std::unique_ptr<SocketServer> ss) in Thread() function in rtc::Thread
355 : Thread(std::move(ss), /*do_init=*/true) {} in Thread()
357 Thread::Thread(SocketServer* ss, bool do_init) in Thread() function in rtc::Thread
366 SetName("Thread", this); // default name in Thread()
372 Thread::Thread(std::unique_ptr<SocketServer> ss, bool do_init) in Thread() function in rtc::Thread
373 : Thread(ss.get(), do_init) { in Thread()
377 Thread::~Thread() { in ~Thread()
382 void Thread::DoInit() { in DoInit()
391 void Thread::DoDestroy() { in DoDestroy()
409 SocketServer* Thread::socketserver() { in socketserver()
413 void Thread::WakeUpSocketServer() { in WakeUpSocketServer()
417 void Thread::Quit() { in Quit()
422 bool Thread::IsQuitting() { in IsQuitting()
426 void Thread::Restart() { in Restart()
430 bool Thread::Peek(Message* pmsg, int cmsWait) { in Peek()
442 bool Thread::Get(Message* pmsg, int cmsWait, bool process_io) { in Get()
533 void Thread::Post(const Location& posted_from, in Post()
544 // Keep thread safe in Post()
560 void Thread::PostDelayed(const Location& posted_from, in PostDelayed()
569 void Thread::PostAt(const Location& posted_from, in PostAt()
578 void Thread::DoDelayPost(const Location& posted_from, in DoDelayPost()
589 // Keep thread safe in DoDelayPost()
611 int Thread::GetDelay() { in GetDelay()
627 void Thread::ClearInternal(MessageHandler* phandler, in ClearInternal()
675 void Thread::Dispatch(Message* pmsg) { in Dispatch()
676 TRACE_EVENT2("webrtc", "Thread::Dispatch", "src_file", in Dispatch()
690 bool Thread::IsCurrent() const { in IsCurrent()
694 std::unique_ptr<Thread> Thread::CreateWithSocketServer() { in CreateWithSocketServer()
695 return std::unique_ptr<Thread>(new Thread(SocketServer::CreateDefault())); in CreateWithSocketServer()
698 std::unique_ptr<Thread> Thread::Create() { in Create()
699 return std::unique_ptr<Thread>( in Create()
700 new Thread(std::unique_ptr<SocketServer>(new NullSocketServer()))); in Create()
703 bool Thread::SleepMs(int milliseconds) { in SleepMs()
724 bool Thread::SetName(const std::string& name, const void* obj) { in SetName()
738 bool Thread::Start() { in Start()
744 Restart(); // reset IsQuitting() if the thread is being restarted in Start()
746 // Make sure that ThreadManager is created on the main thread before in Start()
747 // we start a new thread. in Start()
772 bool Thread::WrapCurrent() { in WrapCurrent()
776 void Thread::UnwrapCurrent() { in UnwrapCurrent()
777 // Clears the platform-specific thread-specific storage. in UnwrapCurrent()
783 << "When unwrapping thread, failed to close handle."; in UnwrapCurrent()
793 void Thread::SafeWrapCurrent() { in SafeWrapCurrent()
797 void Thread::Join() { in Join()
803 RTC_LOG(LS_WARNING) << "Waiting for the thread to join, " in Join()
819 bool Thread::SetAllowBlockingCalls(bool allow) { in SetAllowBlockingCalls()
827 void Thread::AssertBlockingIsAllowedOnCurrentThread() { in AssertBlockingIsAllowedOnCurrentThread()
829 Thread* current = Thread::Current(); in AssertBlockingIsAllowedOnCurrentThread()
836 DWORD WINAPI Thread::PreRun(LPVOID pv) { in PreRun()
838 void* Thread::PreRun(void* pv) { in PreRun()
840 Thread* thread = static_cast<Thread*>(pv); in PreRun() local
841 ThreadManager::Instance()->SetCurrentThread(thread); in PreRun()
842 rtc::SetCurrentThreadName(thread->name_.c_str()); in PreRun()
846 thread->Run(); in PreRun()
856 void Thread::Run() { in PreRun()
860 bool Thread::IsOwned() { in PreRun()
865 void Thread::Stop() { in PreRun()
866 Thread::Quit(); in PreRun()
870 void Thread::Send(const Location& posted_from, in PreRun()
879 // of "thread", like Win32 SendMessage. If in the right context, in PreRun()
893 AutoThread thread; in PreRun() local
894 Thread* current_thread = Thread::Current(); in PreRun()
921 // Thread, that weren't relevant to this Send. Losing these WakeUps can in PreRun()
925 // Win32SocketServer on thread A calls Send on thread B. While processing the in PreRun()
926 // message, thread B Posts a message to A. We consume the wakeup for that in PreRun()
936 void Thread::InvokeInternal(const Location& posted_from, in PreRun()
938 TRACE_EVENT2("webrtc", "Thread::Invoke", "src_file", posted_from.file_name(), in PreRun()
954 // Called by the ThreadManager when being set as the current thread. in PreRun()
955 void Thread::EnsureIsCurrentTaskQueue() { in PreRun()
960 // Called by the ThreadManager when being set as the current thread. in PreRun()
961 void Thread::ClearCurrentTaskQueue() { in PreRun()
965 void Thread::QueuedTaskHandler::OnMessage(Message* msg) { in PreRun()
969 // Thread expects handler to own Message::pdata when OnMessage is called in PreRun()
979 void Thread::AllowInvokesToThread(Thread* thread) { in PreRun() argument
983 [thread, this]() { AllowInvokesToThread(thread); })); in PreRun()
987 allowed_threads_.push_back(thread); in PreRun()
992 void Thread::DisallowAllInvokes() { in PreRun()
1005 // that permits invocation to |target| thread. in PreRun()
1006 bool Thread::IsInvokeToThreadAllowed(rtc::Thread* target) { in PreRun()
1012 for (const auto* thread : allowed_threads_) { in PreRun() local
1013 if (thread == target) { in PreRun()
1023 void Thread::PostTask(std::unique_ptr<webrtc::QueuedTask> task) { in PreRun()
1030 void Thread::PostDelayedTask(std::unique_ptr<webrtc::QueuedTask> task, in PreRun()
1039 void Thread::Delete() { in PreRun()
1044 bool Thread::IsProcessingMessagesForTesting() { in PreRun()
1048 void Thread::Clear(MessageHandler* phandler, in PreRun()
1055 bool Thread::ProcessMessages(int cmsLoop) { in PreRun()
1081 bool Thread::WrapCurrentWithThreadManager(ThreadManager* thread_manager, in PreRun()
1091 RTC_LOG_GLE(LS_ERROR) << "Unable to get handle to thread."; in PreRun()
1104 bool Thread::IsRunning() { in PreRun()
1113 MessageHandler* Thread::GetPostTaskMessageHandler() { in PreRun()
1120 : Thread(SocketServer::CreateDefault(), /*do_init=*/false) { in PreRun()
1123 // be rtc::Thread::Current(), otherwise ProcessAllMessageQueuesInternal will in PreRun()
1124 // post a message to a queue that no running thread is serving. in PreRun()
1139 : Thread(ss, /*do_init=*/false) { in PreRun()
1142 // Temporarily set the current thread to nullptr so that we can keep checks in PreRun()
1153 // Some tests post destroy messages to this thread. To avoid memory in PreRun()
1158 // Stop and destroy the thread before clearing it as the current thread. in PreRun()
1159 // Sometimes there are messages left in the Thread that will be in PreRun()
1161 // its contents rely on this thread still being set as the current thread. in PreRun()