37
37
!defined(DISPATCH_USE_LEGACY_WORKQUEUE_FALLBACK )
38
38
#define DISPATCH_USE_LEGACY_WORKQUEUE_FALLBACK 1
39
39
#endif
40
+ #if HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP || DISPATCH_USE_LEGACY_WORKQUEUE_FALLBACK
41
+ #define DISPATCH_USE_WORKQ_PRIORITY 1
42
+ #endif
40
43
#if DISPATCH_USE_WORKQUEUES && DISPATCH_USE_PTHREAD_POOL && \
41
44
!DISPATCH_USE_LEGACY_WORKQUEUE_FALLBACK
42
45
#define pthread_workqueue_t void*
@@ -154,7 +157,10 @@ struct dispatch_root_queue_context_s {
154
157
int volatile dgq_pending ;
155
158
#if DISPATCH_USE_WORKQUEUES
156
159
qos_class_t dgq_qos ;
157
- int dgq_wq_priority , dgq_wq_options ;
160
+ #if DISPATCH_USE_WORKQ_PRIORITY
161
+ int dgq_wq_priority ;
162
+ #endif
163
+ int dgq_wq_options ;
158
164
#if DISPATCH_USE_LEGACY_WORKQUEUE_FALLBACK || DISPATCH_USE_PTHREAD_POOL
159
165
pthread_workqueue_t dgq_kworkqueue ;
160
166
#endif
@@ -182,7 +188,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
182
188
[DISPATCH_ROOT_QUEUE_IDX_MAINTENANCE_QOS ] = {{{
183
189
#if DISPATCH_USE_WORKQUEUES
184
190
.dgq_qos = QOS_CLASS_MAINTENANCE ,
191
+ #if DISPATCH_USE_WORKQ_PRIORITY
185
192
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE ,
193
+ #endif
186
194
.dgq_wq_options = 0 ,
187
195
#endif
188
196
#if DISPATCH_ENABLE_THREAD_POOL
@@ -193,7 +201,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
193
201
[DISPATCH_ROOT_QUEUE_IDX_MAINTENANCE_QOS_OVERCOMMIT ] = {{{
194
202
#if DISPATCH_USE_WORKQUEUES
195
203
.dgq_qos = QOS_CLASS_MAINTENANCE ,
204
+ #if DISPATCH_USE_WORKQ_PRIORITY
196
205
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE ,
206
+ #endif
197
207
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
198
208
#endif
199
209
#if DISPATCH_ENABLE_THREAD_POOL
@@ -204,7 +214,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
204
214
[DISPATCH_ROOT_QUEUE_IDX_BACKGROUND_QOS ] = {{{
205
215
#if DISPATCH_USE_WORKQUEUES
206
216
.dgq_qos = QOS_CLASS_BACKGROUND ,
217
+ #if DISPATCH_USE_WORKQ_PRIORITY
207
218
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE_CONDITIONAL ,
219
+ #endif
208
220
.dgq_wq_options = 0 ,
209
221
#endif
210
222
#if DISPATCH_ENABLE_THREAD_POOL
@@ -215,7 +227,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
215
227
[DISPATCH_ROOT_QUEUE_IDX_BACKGROUND_QOS_OVERCOMMIT ] = {{{
216
228
#if DISPATCH_USE_WORKQUEUES
217
229
.dgq_qos = QOS_CLASS_BACKGROUND ,
230
+ #if DISPATCH_USE_WORKQ_PRIORITY
218
231
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE_CONDITIONAL ,
232
+ #endif
219
233
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
220
234
#endif
221
235
#if DISPATCH_ENABLE_THREAD_POOL
@@ -226,7 +240,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
226
240
[DISPATCH_ROOT_QUEUE_IDX_UTILITY_QOS ] = {{{
227
241
#if DISPATCH_USE_WORKQUEUES
228
242
.dgq_qos = QOS_CLASS_UTILITY ,
243
+ #if DISPATCH_USE_WORKQ_PRIORITY
229
244
.dgq_wq_priority = WORKQ_LOW_PRIOQUEUE ,
245
+ #endif
230
246
.dgq_wq_options = 0 ,
231
247
#endif
232
248
#if DISPATCH_ENABLE_THREAD_POOL
@@ -237,7 +253,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
237
253
[DISPATCH_ROOT_QUEUE_IDX_UTILITY_QOS_OVERCOMMIT ] = {{{
238
254
#if DISPATCH_USE_WORKQUEUES
239
255
.dgq_qos = QOS_CLASS_UTILITY ,
256
+ #if DISPATCH_USE_WORKQ_PRIORITY
240
257
.dgq_wq_priority = WORKQ_LOW_PRIOQUEUE ,
258
+ #endif
241
259
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
242
260
#endif
243
261
#if DISPATCH_ENABLE_THREAD_POOL
@@ -248,7 +266,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
248
266
[DISPATCH_ROOT_QUEUE_IDX_DEFAULT_QOS ] = {{{
249
267
#if DISPATCH_USE_WORKQUEUES
250
268
.dgq_qos = QOS_CLASS_DEFAULT ,
269
+ #if DISPATCH_USE_WORKQ_PRIORITY
251
270
.dgq_wq_priority = WORKQ_DEFAULT_PRIOQUEUE ,
271
+ #endif
252
272
.dgq_wq_options = 0 ,
253
273
#endif
254
274
#if DISPATCH_ENABLE_THREAD_POOL
@@ -259,7 +279,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
259
279
[DISPATCH_ROOT_QUEUE_IDX_DEFAULT_QOS_OVERCOMMIT ] = {{{
260
280
#if DISPATCH_USE_WORKQUEUES
261
281
.dgq_qos = QOS_CLASS_DEFAULT ,
282
+ #if DISPATCH_USE_WORKQ_PRIORITY
262
283
.dgq_wq_priority = WORKQ_DEFAULT_PRIOQUEUE ,
284
+ #endif
263
285
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
264
286
#endif
265
287
#if DISPATCH_ENABLE_THREAD_POOL
@@ -270,7 +292,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
270
292
[DISPATCH_ROOT_QUEUE_IDX_USER_INITIATED_QOS ] = {{{
271
293
#if DISPATCH_USE_WORKQUEUES
272
294
.dgq_qos = QOS_CLASS_USER_INITIATED ,
295
+ #if DISPATCH_USE_WORKQ_PRIORITY
273
296
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE ,
297
+ #endif
274
298
.dgq_wq_options = 0 ,
275
299
#endif
276
300
#if DISPATCH_ENABLE_THREAD_POOL
@@ -281,7 +305,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
281
305
[DISPATCH_ROOT_QUEUE_IDX_USER_INITIATED_QOS_OVERCOMMIT ] = {{{
282
306
#if DISPATCH_USE_WORKQUEUES
283
307
.dgq_qos = QOS_CLASS_USER_INITIATED ,
308
+ #if DISPATCH_USE_WORKQ_PRIORITY
284
309
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE ,
310
+ #endif
285
311
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
286
312
#endif
287
313
#if DISPATCH_ENABLE_THREAD_POOL
@@ -292,7 +318,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
292
318
[DISPATCH_ROOT_QUEUE_IDX_USER_INTERACTIVE_QOS ] = {{{
293
319
#if DISPATCH_USE_WORKQUEUES
294
320
.dgq_qos = QOS_CLASS_USER_INTERACTIVE ,
321
+ #if DISPATCH_USE_WORKQ_PRIORITY
295
322
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE_CONDITIONAL ,
323
+ #endif
296
324
.dgq_wq_options = 0 ,
297
325
#endif
298
326
#if DISPATCH_ENABLE_THREAD_POOL
@@ -303,7 +331,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
303
331
[DISPATCH_ROOT_QUEUE_IDX_USER_INTERACTIVE_QOS_OVERCOMMIT ] = {{{
304
332
#if DISPATCH_USE_WORKQUEUES
305
333
.dgq_qos = QOS_CLASS_USER_INTERACTIVE ,
334
+ #if DISPATCH_USE_WORKQ_PRIORITY
306
335
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE_CONDITIONAL ,
336
+ #endif
307
337
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
308
338
#endif
309
339
#if DISPATCH_ENABLE_THREAD_POOL
@@ -5511,7 +5541,7 @@ _dispatch_worker_thread(void *context)
5511
5541
bool manager = (dq == & _dispatch_mgr_root_queue );
5512
5542
bool monitored = !(overcommit || manager );
5513
5543
if (monitored ) {
5514
- _dispatch_workq_worker_register (dq , qc -> dgq_wq_priority );
5544
+ _dispatch_workq_worker_register (dq , qc -> dgq_qos );
5515
5545
}
5516
5546
#endif
5517
5547
@@ -5525,7 +5555,7 @@ _dispatch_worker_thread(void *context)
5525
5555
5526
5556
#if DISPATCH_USE_INTERNAL_WORKQUEUE
5527
5557
if (monitored ) {
5528
- _dispatch_workq_worker_unregister (dq , qc -> dgq_wq_priority );
5558
+ _dispatch_workq_worker_unregister (dq , qc -> dgq_qos );
5529
5559
}
5530
5560
#endif
5531
5561
(void )os_atomic_inc2o (qc , dgq_thread_pool_size , release );
0 commit comments