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

Method mt_multi_netfd_poll

adapter/micro_thread/mt_concurrent.cpp:34–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32using namespace NS_MICRO_THREAD;
33
34int NS_MICRO_THREAD::mt_multi_netfd_poll(IMtActList& req_list, int how, int timeout)
35{
36 KqObjList fdlist;
37 TAILQ_INIT(&fdlist);
38
39 KqueuerObj* obj = NULL;
40 IMtAction* action = NULL;
41 for (IMtActList::iterator it = req_list.begin(); it != req_list.end(); ++it)
42 {
43 action = *it;
44 if (action) {
45 obj = action->GetNtfyObj();
46 }
47 if (!action || !obj)
48 {
49 action->SetErrno(ERR_FRAME_ERROR);
50 MTLOG_ERROR("input action %p, or ntify null, error", action);
51 return -1;
52 }
53
54 obj->SetRcvEvents(0);
55 if (how & KQ_EVENT_READ)
56 {
57 obj->EnableInput();
58 }
59 else
60 {
61 obj->DisableInput();
62 }
63
64 if (how & KQ_EVENT_WRITE)
65 {
66 obj->EnableOutput();
67 }
68 else
69 {
70 obj->DisableOutput();
71 }
72
73 TAILQ_INSERT_TAIL(&fdlist, obj, _entry);
74
75 }
76
77 MtFrame* mtframe = MtFrame::Instance();
78 if (!mtframe || !mtframe->KqueueSchedule(&fdlist, NULL, (int)timeout))
79 {
80 if (errno != ETIME)
81 {
82 action->SetErrno(ERR_KQUEUE_FAIL);
83 MTLOG_ERROR("Mtframe %p, epoll schedule failed, errno %d", mtframe, errno);
84 return -2;
85 }
86
87 return -3;
88 }
89
90 return 0;
91}

Callers

nothing calls this directly

Calls 8

SetErrnoMethod · 0.80
SetRcvEventsMethod · 0.80
EnableInputMethod · 0.80
DisableInputMethod · 0.80
EnableOutputMethod · 0.80
DisableOutputMethod · 0.80
GetNtfyObjMethod · 0.45
KqueueScheduleMethod · 0.45

Tested by

no test coverage detected