2424#pragma mark dispatch_unote_t
2525
2626bool
27- _dispatch_unote_register (dispatch_unote_t du DISPATCH_UNUSED ,
28- dispatch_wlh_t wlh DISPATCH_UNUSED ,
29- dispatch_priority_t pri DISPATCH_UNUSED )
27+ _dispatch_unote_register_muxed (dispatch_unote_t du DISPATCH_UNUSED )
3028{
3129 WIN_PORT_ERROR ();
3230 return false;
3331}
3432
3533void
36- _dispatch_unote_resume (dispatch_unote_t du DISPATCH_UNUSED )
34+ _dispatch_unote_resume_muxed (dispatch_unote_t du DISPATCH_UNUSED )
3735{
3836 WIN_PORT_ERROR ();
3937}
4038
4139bool
42- _dispatch_unote_unregister (dispatch_unote_t du DISPATCH_UNUSED ,
43- uint32_t flags DISPATCH_UNUSED )
40+ _dispatch_unote_unregister_muxed (dispatch_unote_t du DISPATCH_UNUSED )
4441{
4542 WIN_PORT_ERROR ();
4643 return false;
@@ -49,31 +46,65 @@ _dispatch_unote_unregister(dispatch_unote_t du DISPATCH_UNUSED,
4946#pragma mark timers
5047
5148void
52- _dispatch_event_loop_timer_arm (uint32_t tidx DISPATCH_UNUSED ,
49+ _dispatch_event_loop_timer_arm (dispatch_timer_heap_t dth DISPATCH_UNUSED ,
50+ uint32_t tidx DISPATCH_UNUSED ,
5351 dispatch_timer_delay_s range DISPATCH_UNUSED ,
5452 dispatch_clock_now_cache_t nows DISPATCH_UNUSED )
5553{
5654 WIN_PORT_ERROR ();
5755}
5856
5957void
60- _dispatch_event_loop_timer_delete (uint32_t tidx DISPATCH_UNUSED )
58+ _dispatch_event_loop_timer_delete (dispatch_timer_heap_t dth DISPATCH_UNUSED ,
59+ uint32_t tidx DISPATCH_UNUSED )
6160{
6261 WIN_PORT_ERROR ();
6362}
6463
6564#pragma mark dispatch_loop
6665
66+ static HANDLE hSomething = INVALID_HANDLE_VALUE ;
67+
68+ static void
69+ _dispatch_something_init (void * context DISPATCH_UNUSED )
70+ {
71+ hSomething = CreateEventW (NULL , /*bManualReset=*/ TRUE,
72+ /*bInitialState=*/ FALSE, NULL );
73+ if (hSomething == NULL ) {
74+ DISPATCH_INTERNAL_CRASH (GetLastError (), "CreateEventW" );
75+ }
76+ }
77+
6778void
6879_dispatch_event_loop_poke (dispatch_wlh_t wlh DISPATCH_UNUSED ,
6980 uint64_t dq_state DISPATCH_UNUSED , uint32_t flags DISPATCH_UNUSED )
7081{
71- WIN_PORT_ERROR ();
82+ static dispatch_once_t _something_pred ;
83+ dispatch_once_f (& _something_pred , NULL , _dispatch_something_init );
84+ BOOL bResult = SetEvent (hSomething );
85+ (void )dispatch_assume_zero (!bResult );
7286}
7387
7488DISPATCH_NOINLINE
7589void
76- _dispatch_event_loop_drain (uint32_t flags DISPATCH_UNUSED )
90+ _dispatch_event_loop_drain (uint32_t flags )
91+ {
92+ DWORD dwWait = WaitForSingleObject (hSomething ,
93+ (flags & KEVENT_FLAG_IMMEDIATE ) ? 0 : INFINITE );
94+ if (dwWait == WAIT_FAILED ) {
95+ DISPATCH_CLIENT_CRASH (GetLastError (), "WaitForSingleObject" );
96+ }
97+
98+ if (dwWait == WAIT_OBJECT_0 ) {
99+ BOOL bResult = ResetEvent (hSomething );
100+ if (!bResult ) {
101+ DISPATCH_INTERNAL_CRASH (GetLastError (), "ResetEvent" );
102+ }
103+ }
104+ }
105+
106+ void
107+ _dispatch_event_loop_cancel_waiter (dispatch_sync_context_t dsc DISPATCH_UNUSED )
77108{
78109 WIN_PORT_ERROR ();
79110}
@@ -109,9 +140,9 @@ _dispatch_event_loop_assert_not_owned(dispatch_wlh_t wlh)
109140#endif
110141
111142void
112- _dispatch_event_loop_leave_immediate (dispatch_wlh_t wlh , uint64_t dq_state )
143+ _dispatch_event_loop_leave_immediate (uint64_t dq_state )
113144{
114- (void )wlh ; ( void ) dq_state ;
145+ (void )dq_state ;
115146}
116147
117148#endif // DISPATCH_EVENT_BACKEND_WINDOWS
0 commit comments