MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / init

Method init

io/kqueue.cpp:46–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 uint32_t _n = 0; // # of events to submit
45
46 int init() {
47 if (_kq >= 0)
48 LOG_ERROR_RETURN(EALREADY, -1, "already init-ed");
49
50 _kq = kqueue();
51 if (_kq < 0)
52 LOG_ERRNO_RETURN(0, -1, "failed to create kqueue()");
53
54 LOG_DEBUG("kqueue_fd = ", _kq);
55 if (enqueue(_kq, EVFILT_USER, EV_ADD | EV_CLEAR, 0, nullptr, true) < 0) {
56 DEFER({ close(_kq); _kq = -1; });
57 LOG_ERRNO_RETURN(0, -1, "failed to setup self-wakeup EVFILT_USER event by kevent()");
58 }
59 return 0;
60 }
61
62 int reset() override {
63 LOG_INFO("Reset event engine: kqueue");

Callers 1

new_kqueue_engineFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected