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*
@@ -158,7 +161,10 @@ struct dispatch_root_queue_context_s {
158
161
int volatile dgq_pending ;
159
162
#if DISPATCH_USE_WORKQUEUES
160
163
qos_class_t dgq_qos ;
161
- int dgq_wq_priority , dgq_wq_options ;
164
+ #if DISPATCH_USE_WORKQ_PRIORITY
165
+ int dgq_wq_priority ;
166
+ #endif
167
+ int dgq_wq_options ;
162
168
#if DISPATCH_USE_LEGACY_WORKQUEUE_FALLBACK || DISPATCH_USE_PTHREAD_POOL
163
169
pthread_workqueue_t dgq_kworkqueue ;
164
170
#endif
@@ -186,7 +192,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
186
192
[DISPATCH_ROOT_QUEUE_IDX_MAINTENANCE_QOS ] = {{{
187
193
#if DISPATCH_USE_WORKQUEUES
188
194
.dgq_qos = QOS_CLASS_MAINTENANCE ,
195
+ #if DISPATCH_USE_WORKQ_PRIORITY
189
196
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE ,
197
+ #endif
190
198
.dgq_wq_options = 0 ,
191
199
#endif
192
200
#if DISPATCH_ENABLE_THREAD_POOL
@@ -197,7 +205,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
197
205
[DISPATCH_ROOT_QUEUE_IDX_MAINTENANCE_QOS_OVERCOMMIT ] = {{{
198
206
#if DISPATCH_USE_WORKQUEUES
199
207
.dgq_qos = QOS_CLASS_MAINTENANCE ,
208
+ #if DISPATCH_USE_WORKQ_PRIORITY
200
209
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE ,
210
+ #endif
201
211
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
202
212
#endif
203
213
#if DISPATCH_ENABLE_THREAD_POOL
@@ -208,7 +218,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
208
218
[DISPATCH_ROOT_QUEUE_IDX_BACKGROUND_QOS ] = {{{
209
219
#if DISPATCH_USE_WORKQUEUES
210
220
.dgq_qos = QOS_CLASS_BACKGROUND ,
221
+ #if DISPATCH_USE_WORKQ_PRIORITY
211
222
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE_CONDITIONAL ,
223
+ #endif
212
224
.dgq_wq_options = 0 ,
213
225
#endif
214
226
#if DISPATCH_ENABLE_THREAD_POOL
@@ -219,7 +231,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
219
231
[DISPATCH_ROOT_QUEUE_IDX_BACKGROUND_QOS_OVERCOMMIT ] = {{{
220
232
#if DISPATCH_USE_WORKQUEUES
221
233
.dgq_qos = QOS_CLASS_BACKGROUND ,
234
+ #if DISPATCH_USE_WORKQ_PRIORITY
222
235
.dgq_wq_priority = WORKQ_BG_PRIOQUEUE_CONDITIONAL ,
236
+ #endif
223
237
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
224
238
#endif
225
239
#if DISPATCH_ENABLE_THREAD_POOL
@@ -230,7 +244,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
230
244
[DISPATCH_ROOT_QUEUE_IDX_UTILITY_QOS ] = {{{
231
245
#if DISPATCH_USE_WORKQUEUES
232
246
.dgq_qos = QOS_CLASS_UTILITY ,
247
+ #if DISPATCH_USE_WORKQ_PRIORITY
233
248
.dgq_wq_priority = WORKQ_LOW_PRIOQUEUE ,
249
+ #endif
234
250
.dgq_wq_options = 0 ,
235
251
#endif
236
252
#if DISPATCH_ENABLE_THREAD_POOL
@@ -241,7 +257,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
241
257
[DISPATCH_ROOT_QUEUE_IDX_UTILITY_QOS_OVERCOMMIT ] = {{{
242
258
#if DISPATCH_USE_WORKQUEUES
243
259
.dgq_qos = QOS_CLASS_UTILITY ,
260
+ #if DISPATCH_USE_WORKQ_PRIORITY
244
261
.dgq_wq_priority = WORKQ_LOW_PRIOQUEUE ,
262
+ #endif
245
263
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
246
264
#endif
247
265
#if DISPATCH_ENABLE_THREAD_POOL
@@ -252,7 +270,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
252
270
[DISPATCH_ROOT_QUEUE_IDX_DEFAULT_QOS ] = {{{
253
271
#if DISPATCH_USE_WORKQUEUES
254
272
.dgq_qos = QOS_CLASS_DEFAULT ,
273
+ #if DISPATCH_USE_WORKQ_PRIORITY
255
274
.dgq_wq_priority = WORKQ_DEFAULT_PRIOQUEUE ,
275
+ #endif
256
276
.dgq_wq_options = 0 ,
257
277
#endif
258
278
#if DISPATCH_ENABLE_THREAD_POOL
@@ -263,7 +283,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
263
283
[DISPATCH_ROOT_QUEUE_IDX_DEFAULT_QOS_OVERCOMMIT ] = {{{
264
284
#if DISPATCH_USE_WORKQUEUES
265
285
.dgq_qos = QOS_CLASS_DEFAULT ,
286
+ #if DISPATCH_USE_WORKQ_PRIORITY
266
287
.dgq_wq_priority = WORKQ_DEFAULT_PRIOQUEUE ,
288
+ #endif
267
289
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
268
290
#endif
269
291
#if DISPATCH_ENABLE_THREAD_POOL
@@ -274,7 +296,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
274
296
[DISPATCH_ROOT_QUEUE_IDX_USER_INITIATED_QOS ] = {{{
275
297
#if DISPATCH_USE_WORKQUEUES
276
298
.dgq_qos = QOS_CLASS_USER_INITIATED ,
299
+ #if DISPATCH_USE_WORKQ_PRIORITY
277
300
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE ,
301
+ #endif
278
302
.dgq_wq_options = 0 ,
279
303
#endif
280
304
#if DISPATCH_ENABLE_THREAD_POOL
@@ -285,7 +309,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
285
309
[DISPATCH_ROOT_QUEUE_IDX_USER_INITIATED_QOS_OVERCOMMIT ] = {{{
286
310
#if DISPATCH_USE_WORKQUEUES
287
311
.dgq_qos = QOS_CLASS_USER_INITIATED ,
312
+ #if DISPATCH_USE_WORKQ_PRIORITY
288
313
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE ,
314
+ #endif
289
315
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
290
316
#endif
291
317
#if DISPATCH_ENABLE_THREAD_POOL
@@ -296,7 +322,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
296
322
[DISPATCH_ROOT_QUEUE_IDX_USER_INTERACTIVE_QOS ] = {{{
297
323
#if DISPATCH_USE_WORKQUEUES
298
324
.dgq_qos = QOS_CLASS_USER_INTERACTIVE ,
325
+ #if DISPATCH_USE_WORKQ_PRIORITY
299
326
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE_CONDITIONAL ,
327
+ #endif
300
328
.dgq_wq_options = 0 ,
301
329
#endif
302
330
#if DISPATCH_ENABLE_THREAD_POOL
@@ -307,7 +335,9 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
307
335
[DISPATCH_ROOT_QUEUE_IDX_USER_INTERACTIVE_QOS_OVERCOMMIT ] = {{{
308
336
#if DISPATCH_USE_WORKQUEUES
309
337
.dgq_qos = QOS_CLASS_USER_INTERACTIVE ,
338
+ #if DISPATCH_USE_WORKQ_PRIORITY
310
339
.dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE_CONDITIONAL ,
340
+ #endif
311
341
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
312
342
#endif
313
343
#if DISPATCH_ENABLE_THREAD_POOL
@@ -5809,7 +5839,7 @@ _dispatch_worker_thread(void *context)
5809
5839
bool manager = (dq == & _dispatch_mgr_root_queue );
5810
5840
bool monitored = !(overcommit || manager );
5811
5841
if (monitored ) {
5812
- _dispatch_workq_worker_register (dq , qc -> dgq_wq_priority );
5842
+ _dispatch_workq_worker_register (dq , qc -> dgq_qos );
5813
5843
}
5814
5844
#endif
5815
5845
@@ -5823,7 +5853,7 @@ _dispatch_worker_thread(void *context)
5823
5853
5824
5854
#if DISPATCH_USE_INTERNAL_WORKQUEUE
5825
5855
if (monitored ) {
5826
- _dispatch_workq_worker_unregister (dq , qc -> dgq_wq_priority );
5856
+ _dispatch_workq_worker_unregister (dq , qc -> dgq_qos );
5827
5857
}
5828
5858
#endif
5829
5859
(void )os_atomic_inc2o (qc , dgq_thread_pool_size , release );
0 commit comments