Lines Matching refs:thread

322     MicroThread* thread = frame->GetActiveThread();  in ScheduleSleep()  local
323 if ((!frame) || (!thread)) { in ScheduleSleep()
324 MTLOG_ERROR("frame and act thread null, %p, %p", frame, thread); in ScheduleSleep()
328 frame->InsertSleep(thread); in ScheduleSleep()
335 MicroThread* thread = frame->GetActiveThread(); in SchedulePend() local
336 if ((!frame) || (!thread)) { in SchedulePend()
337 MTLOG_ERROR("frame and act thread null, %p, %p", frame, thread); in SchedulePend()
341 frame->InsertPend(thread); in SchedulePend()
348 MicroThread* thread = (MicroThread*)pthread; in ScheduleUnpend() local
349 if ((!frame) || (!thread)) { in ScheduleUnpend()
350 MTLOG_ERROR("frame and act thread null, %p, %p", frame, thread); in ScheduleUnpend()
354 frame->RemovePend(thread); in ScheduleUnpend()
355 frame->InsertRunable(thread); in ScheduleUnpend()
361 MicroThread* thread = frame->GetActiveThread(); in ScheduleReclaim() local
362 if ((!frame) || (!thread)) { in ScheduleReclaim()
363 MTLOG_ERROR("frame and act thread null, %p, %p", frame, thread); in ScheduleReclaim()
367 frame->FreeThread(thread); in ScheduleReclaim()
373 MicroThread* thread = frame->GetActiveThread(); in ScheduleStartRun() local
374 if ((!frame) || (!thread)) { in ScheduleStartRun()
375 MTLOG_ERROR("frame and act thread null, %p, %p", frame, thread); in ScheduleStartRun()
379 thread->Run(); in ScheduleStartRun()
389 MicroThread *thread = NULL; in InitialPool() local
392 thread = new MicroThread(); in InitialPool()
393 if ((NULL == thread) || (false == thread->Initial())) in InitialPool()
395 MTLOG_ERROR("init pool, thread %p init failed", thread); in InitialPool()
396 if (thread) delete thread; in InitialPool()
399 thread->SetFlag(MicroThread::FREE_LIST); in InitialPool()
400 _freelist.push(thread); in InitialPool()
418 MicroThread* thread = NULL; in DestroyPool() local
421 thread = _freelist.front(); in DestroyPool()
423 thread->Destroy(); in DestroyPool()
424 delete thread; in DestroyPool()
435 MicroThread* thread = NULL; in AllocThread() local
438 thread = _freelist.front(); in AllocThread()
441 ASSERT(thread->HasFlag(MicroThread::FREE_LIST)); in AllocThread()
443 thread->UnsetFlag(MicroThread::FREE_LIST); in AllocThread()
445 return thread; in AllocThread()
456 thread = new MicroThread(); in AllocThread()
457 if ((NULL == thread) || (false == thread->Initial())) in AllocThread()
460 MTLOG_ERROR("thread alloc failed, thread: %p", thread); in AllocThread()
461 if (thread) delete thread; in AllocThread()
473 return thread; in AllocThread()
476 void ThreadPool::FreeThread(MicroThread* thread) in FreeThread() argument
478 ASSERT(!thread->HasFlag(MicroThread::FREE_LIST)); in FreeThread()
479 thread->Reset(); in FreeThread()
481 _freelist.push(thread); in FreeThread()
482 thread->SetFlag(MicroThread::FREE_LIST); in FreeThread()
487 thread = _freelist.front(); in FreeThread()
489 thread->Destroy(); in FreeThread()
490 delete thread; in FreeThread()
598 MicroThread* thread = dynamic_cast<MicroThread*>(_sleeplist.HeapPop()); in Destroy() local
599 while (thread) in Destroy()
601 FreeThread(thread); in Destroy()
602 thread = dynamic_cast<MicroThread*>(_sleeplist.HeapPop()); in Destroy()
607 thread = _runlist.front(); in Destroy()
609 FreeThread(thread); in Destroy()
613 TAILQ_FOREACH_SAFE(thread, &_pend_list, _entry, tmp) in Destroy()
615 TAILQ_REMOVE(&_pend_list, thread, _entry); in Destroy()
616 FreeThread(thread); in Destroy()
639 MicroThread* thread = mtframe->AllocThread(); in CreateThread() local
640 if (NULL == thread) in CreateThread()
645 thread->SetSartFunc(entry, args); in CreateThread()
648 mtframe->InsertRunable(thread); in CreateThread()
651 return thread; in CreateThread()
693 MicroThread *thread = _curr_thread; in GetRootThread() local
694 MicroThread *parent = thread; in GetRootThread()
698 thread = thread->GetParent(); in GetRootThread()
699 if (!thread) in GetRootThread()
704 type = thread->GetType(); in GetRootThread()
705 parent = thread; in GetRootThread()
713 MicroThread* thread = NULL; in ThreadSchdule() local
718 thread = mtframe->DaemonThread(); in ThreadSchdule()
722 thread = mtframe->_runlist.front(); in ThreadSchdule()
723 mtframe->RemoveRunable(thread); in ThreadSchdule()
726 this->SetActiveThread(thread); in ThreadSchdule()
727 thread->SetState(MicroThread::RUNNING); in ThreadSchdule()
728 thread->RestoreContext(); in ThreadSchdule()
752 MicroThread* thread = dynamic_cast<MicroThread*>(_sleeplist.HeapTop()); in WakeupTimeout() local
753 while (thread && (thread->GetWakeupTime() <= now)) in WakeupTimeout()
755 if (thread->HasFlag(MicroThread::IO_LIST)) in WakeupTimeout()
757 RemoveIoWait(thread); in WakeupTimeout()
761 RemoveSleep(thread); in WakeupTimeout()
764 InsertRunable(thread); in WakeupTimeout()
766 thread = dynamic_cast<MicroThread*>(_sleeplist.HeapTop()); in WakeupTimeout()
773 MicroThread* thread = dynamic_cast<MicroThread*>(_sleeplist.HeapTop()); in KqueueGetTimeout() local
774 if (!thread) in KqueueGetTimeout()
778 else if (thread->GetWakeupTime() < now) in KqueueGetTimeout()
784 return (int)(thread->GetWakeupTime() - now); in KqueueGetTimeout()
788 inline void MtFrame::InsertSleep(MicroThread* thread) in InsertSleep() argument
790 ASSERT(!thread->HasFlag(MicroThread::SLEEP_LIST)); in InsertSleep()
792 thread->SetFlag(MicroThread::SLEEP_LIST); in InsertSleep()
793 thread->SetState(MicroThread::SLEEPING); in InsertSleep()
794 int rc = _sleeplist.HeapPush(thread); in InsertSleep()
802 inline void MtFrame::RemoveSleep(MicroThread* thread) in RemoveSleep() argument
804 ASSERT(thread->HasFlag(MicroThread::SLEEP_LIST)); in RemoveSleep()
805 thread->UnsetFlag(MicroThread::SLEEP_LIST); in RemoveSleep()
807 int rc = _sleeplist.HeapDelete(thread); in RemoveSleep()
815 inline void MtFrame::InsertIoWait(MicroThread* thread) in InsertIoWait() argument
817 ASSERT(!thread->HasFlag(MicroThread::IO_LIST)); in InsertIoWait()
818 thread->SetFlag(MicroThread::IO_LIST); in InsertIoWait()
819 TAILQ_INSERT_TAIL(&_iolist, thread, _entry); in InsertIoWait()
820 InsertSleep(thread); in InsertIoWait()
823 void MtFrame::RemoveIoWait(MicroThread* thread) in RemoveIoWait() argument
825 ASSERT(thread->HasFlag(MicroThread::IO_LIST)); in RemoveIoWait()
826 thread->UnsetFlag(MicroThread::IO_LIST); in RemoveIoWait()
827 TAILQ_REMOVE(&_iolist, thread, _entry); in RemoveIoWait()
829 RemoveSleep(thread); in RemoveIoWait()
832 void MtFrame::InsertRunable(MicroThread* thread) in InsertRunable() argument
834 ASSERT(!thread->HasFlag(MicroThread::RUN_LIST)); in InsertRunable()
835 thread->SetFlag(MicroThread::RUN_LIST); in InsertRunable()
837 thread->SetState(MicroThread::RUNABLE); in InsertRunable()
838 _runlist.push(thread); in InsertRunable()
842 inline void MtFrame::RemoveRunable(MicroThread* thread) in RemoveRunable() argument
844 ASSERT(thread->HasFlag(MicroThread::RUN_LIST)); in RemoveRunable()
845 ASSERT(thread == _runlist.front()); in RemoveRunable()
846 thread->UnsetFlag(MicroThread::RUN_LIST); in RemoveRunable()
852 void MtFrame::InsertPend(MicroThread* thread) in InsertPend() argument
854 ASSERT(!thread->HasFlag(MicroThread::PEND_LIST)); in InsertPend()
855 thread->SetFlag(MicroThread::PEND_LIST); in InsertPend()
856 TAILQ_INSERT_TAIL(&_pend_list, thread, _entry); in InsertPend()
857 thread->SetState(MicroThread::PENDING); in InsertPend()
860 void MtFrame::RemovePend(MicroThread* thread) in RemovePend() argument
862 ASSERT(thread->HasFlag(MicroThread::PEND_LIST)); in RemovePend()
863 thread->UnsetFlag(MicroThread::PEND_LIST); in RemovePend()
864 TAILQ_REMOVE(&_pend_list, thread, _entry); in RemovePend()
869 MicroThread* thread = GetActiveThread(); in WaitNotify() local
871 thread->SetWakeupTime(timeout + this->GetLastClock()); in WaitNotify()
872 this->InsertIoWait(thread); in WaitNotify()
873 thread->SwitchContext(); in WaitNotify()
876 void MtFrame::NotifyThread(MicroThread* thread) in NotifyThread() argument
878 if(thread == NULL){ in NotifyThread()
882 if (thread->HasFlag(MicroThread::IO_LIST)) in NotifyThread()
884 this->RemoveIoWait(thread); in NotifyThread()
888 this->SetActiveThread(thread); in NotifyThread()
889 thread->SetState(MicroThread::RUNNING); in NotifyThread()
890 thread->RestoreContext(); in NotifyThread()
893 this->InsertRunable(thread); in NotifyThread()
900 MicroThread* thread = GetActiveThread(); in SwapDaemonThread() local
902 if(thread != daemon_thread){ in SwapDaemonThread()
903 if(thread->SaveContext() == 0){ in SwapDaemonThread()
904 this->InsertRunable(thread); in SwapDaemonThread()
914 MicroThread* thread = GetActiveThread(); in KqueueSchedule() local
915 if (NULL == thread) in KqueueSchedule()
921 thread->ClearAllFd(); in KqueueSchedule()
924 thread->AddFdList(fdlist); in KqueueSchedule()
928 thread->AddFd(fd); in KqueueSchedule()
931 thread->SetWakeupTime(timeout + this->GetLastClock()); in KqueueSchedule()
932 if (!this->KqueueAdd(thread->GetFdSet())) in KqueueSchedule()
937 this->InsertIoWait(thread); in KqueueSchedule()
938 thread->SwitchContext(); in KqueueSchedule()
941 KqObjList& rcvfds = thread->GetFdSet(); in KqueueSchedule()
965 MicroThread* thread = mtframe->GetActiveThread(); in recvfrom() local
992 epfd.SetOwnerThread(thread); in recvfrom()
1025 MicroThread* thread = mtframe->GetActiveThread(); in sendto() local
1058 epfd.SetOwnerThread(thread); in sendto()
1071 MicroThread* thread = mtframe->GetActiveThread(); in connect() local
1109 epfd.SetOwnerThread(thread); in connect()
1122 MicroThread* thread = mtframe->GetActiveThread(); in accept() local
1155 epfd.SetOwnerThread(thread); in accept()
1168 MicroThread* thread = mtframe->GetActiveThread(); in read() local
1201 epfd.SetOwnerThread(thread); in read()
1214 MicroThread* thread = mtframe->GetActiveThread(); in write() local
1259 epfd.SetOwnerThread(thread); in write()
1272 MicroThread* thread = mtframe->GetActiveThread(); in recv() local
1299 epfd.SetOwnerThread(thread); in recv()
1332 MicroThread* thread = mtframe->GetActiveThread(); in send() local
1377 epfd.SetOwnerThread(thread); in send()
1389 MicroThread* thread = frame->GetActiveThread(); in sleep() local
1390 if (thread != NULL) in sleep()
1392 thread->sleep(ms); in sleep()
1400 MicroThread* thread = mtframe->GetActiveThread(); in WaitEvents() local
1427 epfd.SetOwnerThread(thread); in WaitEvents()