2 from folly cimport cFollyExecutor
3 from folly.executor cimport cNotificationQueueExecutor
4 from libcpp.memory cimport make_unique, unique_ptr
5 from cython.operator cimport dereference as deref
7 #asynico Loops to NotificationQueueExecutor
11 cdef class NotificationQueueExecutor:
13 self.cQ = make_unique[cNotificationQueueExecutor]();
15 def fileno(NotificationQueueExecutor self):
16 return deref(self.cQ).fileno()
18 def drive(NotificationQueueExecutor self):
19 deref(self.cQ).drive()
21 def __dealloc__(NotificationQueueExecutor self):
22 # We drive it one last time
23 deref(self.cQ).drive()
26 cdef cFollyExecutor* get_executor():
27 loop = asyncio.get_event_loop()
29 Q = <NotificationQueueExecutor>(loop_to_q[loop])
31 Q = NotificationQueueExecutor()
32 loop.add_reader(Q.fileno(), Q.drive)