MCPcopy Create free account
hub / github.com/F-Stack/f-stack / KqueueSchedule

Method KqueueSchedule

adapter/micro_thread/micro_thread.cpp:912–959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

910}
911
912bool MtFrame::KqueueSchedule(KqObjList* fdlist, KqueuerObj* fd, int timeout)
913{
914 MicroThread* thread = GetActiveThread();
915 if (NULL == thread)
916 {
917 MTLOG_ERROR("active thread null, epoll schedule failed");
918 return false;
919 }
920
921 thread->ClearAllFd();
922 if (fdlist)
923 {
924 thread->AddFdList(fdlist);
925 }
926 if (fd)
927 {
928 thread->AddFd(fd);
929 }
930
931 thread->SetWakeupTime(timeout + this->GetLastClock());
932 if (!this->KqueueAdd(thread->GetFdSet()))
933 {
934 MTLOG_ERROR("epoll add failed, errno: %d", errno);
935 return false;
936 }
937 this->InsertIoWait(thread);
938 thread->SwitchContext();
939
940 int rcvnum = 0;
941 KqObjList& rcvfds = thread->GetFdSet();
942 KqueuerObj* fdata = NULL;
943 TAILQ_FOREACH(fdata, &rcvfds, _entry)
944 {
945 if (fdata->GetRcvEvents() != 0)
946 {
947 rcvnum++;
948 }
949 }
950 this->KqueueDel(rcvfds);
951
952 if (rcvnum == 0)
953 {
954 errno = ETIME;
955 return false;
956 }
957
958 return true;
959}
960
961int MtFrame::recvfrom(int fd, void *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen, int timeout)
962{

Callers 10

mt_multi_netfd_pollMethod · 0.45
recvfromMethod · 0.45
sendtoMethod · 0.45
connectMethod · 0.45
acceptMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
recvMethod · 0.45
sendMethod · 0.45
WaitEventsMethod · 0.45

Calls 10

GetLastClockMethod · 0.95
InsertIoWaitMethod · 0.95
ClearAllFdMethod · 0.80
AddFdListMethod · 0.80
AddFdMethod · 0.80
SetWakeupTimeMethod · 0.80
KqueueAddMethod · 0.80
SwitchContextMethod · 0.80
GetRcvEventsMethod · 0.80
KqueueDelMethod · 0.80

Tested by

no test coverage detected