@@ -93,10 +93,14 @@ _dispatch_worker_thread_thunk(LPVOID lpParameter);
93
93
#endif
94
94
#endif
95
95
96
- #if DISPATCH_COCOA_COMPAT
96
+ #if DISPATCH_COCOA_COMPAT || defined( _WIN32 )
97
97
static dispatch_once_t _dispatch_main_q_handle_pred ;
98
+ #endif
99
+ #if DISPATCH_COCOA_COMPAT
98
100
static void _dispatch_runloop_queue_poke (dispatch_queue_t dq ,
99
101
dispatch_qos_t qos , dispatch_wakeup_flags_t flags );
102
+ #endif
103
+ #if DISPATCH_COCOA_COMPAT || defined(_WIN32 )
100
104
static void _dispatch_runloop_queue_handle_init (void * ctxt );
101
105
static void _dispatch_runloop_queue_handle_dispose (dispatch_queue_t dq );
102
106
#endif
@@ -4476,7 +4480,7 @@ _dispatch_queue_wakeup(dispatch_queue_t dq, dispatch_qos_t qos,
4476
4480
return _dispatch_queue_class_wakeup (dq , qos , flags , target );
4477
4481
}
4478
4482
4479
- #if DISPATCH_COCOA_COMPAT
4483
+ #if DISPATCH_COCOA_COMPAT || defined( _WIN32 )
4480
4484
DISPATCH_ALWAYS_INLINE
4481
4485
static inline bool
4482
4486
_dispatch_runloop_handle_is_valid (dispatch_runloop_handle_t handle )
@@ -4485,6 +4489,8 @@ _dispatch_runloop_handle_is_valid(dispatch_runloop_handle_t handle)
4485
4489
return MACH_PORT_VALID (handle );
4486
4490
#elif defined(__linux__ )
4487
4491
return handle >= 0 ;
4492
+ #elif defined(_WIN32 )
4493
+ return handle != INVALID_HANDLE_VALUE ;
4488
4494
#else
4489
4495
#error "runloop support not implemented on this platform"
4490
4496
#endif
@@ -4499,6 +4505,8 @@ _dispatch_runloop_queue_get_handle(dispatch_queue_t dq)
4499
4505
#elif defined(__linux__ )
4500
4506
// decode: 0 is a valid fd, so offset by 1 to distinguish from NULL
4501
4507
return ((dispatch_runloop_handle_t )(uintptr_t )dq -> do_ctxt ) - 1 ;
4508
+ #elif defined(_WIN32 )
4509
+ return ((dispatch_runloop_handle_t )(uintptr_t )dq -> do_ctxt );
4502
4510
#else
4503
4511
#error "runloop support not implemented on this platform"
4504
4512
#endif
@@ -4513,6 +4521,8 @@ _dispatch_runloop_queue_set_handle(dispatch_queue_t dq, dispatch_runloop_handle_
4513
4521
#elif defined(__linux__ )
4514
4522
// encode: 0 is a valid fd, so offset by 1 to distinguish from NULL
4515
4523
dq -> do_ctxt = (void * )(uintptr_t )(handle + 1 );
4524
+ #elif defined(_WIN32 )
4525
+ dq -> do_ctxt = (void * )(uintptr_t )handle ;
4516
4526
#else
4517
4527
#error "runloop support not implemented on this platform"
4518
4528
#endif
@@ -4527,7 +4537,7 @@ _dispatch_runloop_queue_reset_max_qos(dispatch_queue_class_t dqu)
4527
4537
old_state = os_atomic_and_orig2o (dqu ._dq , dq_state , ~clear_bits , relaxed );
4528
4538
return _dq_state_max_qos (old_state );
4529
4539
}
4530
- #endif // DISPATCH_COCOA_COMPAT
4540
+ #endif
4531
4541
4532
4542
void
4533
4543
_dispatch_runloop_queue_wakeup (dispatch_queue_t dq , dispatch_qos_t qos ,
@@ -5112,7 +5122,7 @@ _dispatch_queue_serial_drain(dispatch_queue_t dq, dispatch_invoke_context_t dic,
5112
5122
return _dispatch_queue_drain (dq , dic , flags , owned , true);
5113
5123
}
5114
5124
5115
- #if DISPATCH_COCOA_COMPAT
5125
+ #if DISPATCH_COCOA_COMPAT || defined( _WIN32 )
5116
5126
DISPATCH_NOINLINE
5117
5127
static void
5118
5128
_dispatch_main_queue_update_priority_from_thread (void )
@@ -6178,7 +6188,7 @@ _dispatch_network_root_queue_create_4NW(const char *label,
6178
6188
6179
6189
static bool _dispatch_program_is_probably_callback_driven ;
6180
6190
6181
- #if DISPATCH_COCOA_COMPAT
6191
+ #if DISPATCH_COCOA_COMPAT || defined( _WIN32 )
6182
6192
6183
6193
dispatch_queue_t
6184
6194
_dispatch_runloop_root_queue_create_4CF (const char * label , unsigned long flags )
@@ -6242,7 +6252,7 @@ _dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t dq)
6242
6252
_dispatch_runloop_queue_wakeup (dq , 0 , false);
6243
6253
}
6244
6254
6245
- #if TARGET_OS_MAC
6255
+ #if TARGET_OS_MAC || defined( _WIN32 )
6246
6256
dispatch_runloop_handle_t
6247
6257
_dispatch_runloop_root_queue_get_port_4CF (dispatch_queue_t dq )
6248
6258
{
@@ -6305,6 +6315,8 @@ _dispatch_runloop_queue_handle_init(void *ctxt)
6305
6315
}
6306
6316
}
6307
6317
handle = fd ;
6318
+ #elif defined(_WIN32 )
6319
+ handle = INVALID_HANDLE_VALUE ;
6308
6320
#else
6309
6321
#error "runloop support not implemented on this platform"
6310
6322
#endif
@@ -6332,6 +6344,8 @@ _dispatch_runloop_queue_handle_dispose(dispatch_queue_t dq)
6332
6344
#elif defined(__linux__ )
6333
6345
int rc = close (handle );
6334
6346
(void )dispatch_assume_zero (rc );
6347
+ #elif defined(_WIN32 )
6348
+ CloseHandle (handle );
6335
6349
#else
6336
6350
#error "runloop support not implemented on this platform"
6337
6351
#endif
0 commit comments