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

Method WaitEvents

adapter/micro_thread/micro_thread.cpp:1396–1437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1394}
1395
1396int MtFrame::WaitEvents(int fd, int events, int timeout)
1397{
1398 MtFrame* mtframe = MtFrame::Instance();
1399 utime64_t start = mtframe->GetLastClock();
1400 MicroThread* thread = mtframe->GetActiveThread();
1401 utime64_t now = 0;
1402
1403 if (timeout <= -1)
1404 {
1405 timeout = 0x7fffffff;
1406 }
1407
1408 while (true)
1409 {
1410 now = mtframe->GetLastClock();
1411 if ((int)(now - start) > timeout)
1412 {
1413 errno = ETIME;
1414 return 0;
1415 }
1416
1417 KqueuerObj epfd;
1418 epfd.SetOsfd(fd);
1419 if (events & KQ_EVENT_READ)
1420 {
1421 epfd.EnableInput();
1422 }
1423 if (events & KQ_EVENT_WRITE)
1424 {
1425 epfd.EnableOutput();
1426 }
1427 epfd.SetOwnerThread(thread);
1428
1429 if (!mtframe->KqueueSchedule(NULL, &epfd, timeout))
1430 {
1431 MTLOG_TRACE("epoll schedule failed, errno: %d", errno);
1432 return 0;
1433 }
1434
1435 return epfd.GetRcvEvents();
1436 }
1437}

Callers 1

mt_wait_eventsFunction · 0.80

Calls 8

GetLastClockMethod · 0.80
GetActiveThreadMethod · 0.80
SetOsfdMethod · 0.80
EnableInputMethod · 0.80
EnableOutputMethod · 0.80
GetRcvEventsMethod · 0.80
SetOwnerThreadMethod · 0.45
KqueueScheduleMethod · 0.45

Tested by

no test coverage detected