Skip to content

Commit 13129d9

Browse files
committed
Make workloop scheduling depend on TARGET_OS_MAC
1 parent aac4452 commit 13129d9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/queue.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3939,7 +3939,6 @@ _dispatch_workloop_has_kernel_attributes(dispatch_workloop_t dwl)
39393939
DISPATCH_WORKLOOP_ATTR_HAS_POLICY |
39403940
DISPATCH_WORKLOOP_ATTR_HAS_CPUPERCENT));
39413941
}
3942-
#endif // TARGET_OS_MAC
39433942

39443943
void
39453944
dispatch_workloop_set_scheduler_priority(dispatch_workloop_t dwl, int priority,
@@ -3963,6 +3962,7 @@ dispatch_workloop_set_scheduler_priority(dispatch_workloop_t dwl, int priority,
39633962
dwl->dwl_attr->dwla_flags &= ~DISPATCH_WORKLOOP_ATTR_HAS_POLICY;
39643963
}
39653964
}
3965+
#endif // TARGET_OS_MAC
39663966

39673967
void
39683968
dispatch_workloop_set_qos_class_floor(dispatch_workloop_t dwl,
@@ -3981,12 +3981,16 @@ dispatch_workloop_set_qos_class_floor(dispatch_workloop_t dwl,
39813981
dwl->dwl_attr->dwla_flags &= ~DISPATCH_WORKLOOP_ATTR_HAS_QOS_CLASS;
39823982
}
39833983

3984+
#if TARGET_OS_MAC
39843985
if (flags & DISPATCH_WORKLOOP_FIXED_PRIORITY) {
39853986
dwl->dwl_attr->dwla_policy = POLICY_RR;
39863987
dwl->dwl_attr->dwla_flags |= DISPATCH_WORKLOOP_ATTR_HAS_POLICY;
39873988
} else {
39883989
dwl->dwl_attr->dwla_flags &= ~DISPATCH_WORKLOOP_ATTR_HAS_POLICY;
39893990
}
3991+
#else // TARGET_OS_MAC
3992+
(void)flags;
3993+
#endif // TARGET_OS_MAC
39903994
}
39913995

39923996
void
@@ -4034,7 +4038,6 @@ _dispatch_workloop_activate_simulator_fallback(dispatch_workloop_t dwl,
40344038
new_state |= DISPATCH_QUEUE_ROLE_BASE_ANON;
40354039
});
40364040
}
4037-
#endif // TARGET_OS_MAC
40384041

40394042
static const struct dispatch_queue_global_s _dispatch_custom_workloop_root_queue = {
40404043
DISPATCH_GLOBAL_OBJECT_HEADER(queue_global),
@@ -4047,6 +4050,7 @@ static const struct dispatch_queue_global_s _dispatch_custom_workloop_root_queue
40474050
.dq_serialnum = DISPATCH_QUEUE_SERIAL_NUMBER_WLF,
40484051
.dgq_thread_pool_size = 1,
40494052
};
4053+
#endif // TARGET_OS_MAC
40504054

40514055
static void
40524056
_dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
@@ -4058,6 +4062,7 @@ _dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
40584062
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_QOS_CLASS) {
40594063
dwl->dq_priority |= dwla->dwla_pri | DISPATCH_PRIORITY_FLAG_FLOOR;
40604064
}
4065+
#if TARGET_OS_MAC
40614066
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_SCHED) {
40624067
pthread_attr_setschedparam(&attr, &dwla->dwla_sched);
40634068
// _dispatch_async_and_wait_should_always_async detects when a queue
@@ -4070,6 +4075,7 @@ _dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
40704075
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_POLICY) {
40714076
pthread_attr_setschedpolicy(&attr, dwla->dwla_policy);
40724077
}
4078+
#endif // TARGET_OS_MAC
40734079
#if HAVE_PTHREAD_ATTR_SETCPUPERCENT_NP
40744080
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_CPUPERCENT) {
40754081
pthread_attr_setcpupercent_np(&attr, dwla->dwla_cpupercent.percent,

src/queue_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ typedef struct dispatch_workloop_attr_s *dispatch_workloop_attr_t;
470470
typedef struct dispatch_workloop_attr_s {
471471
uint32_t dwla_flags;
472472
dispatch_priority_t dwla_pri;
473+
#if TARGET_OS_MAC
473474
struct sched_param dwla_sched;
475+
#endif // TARGET_OS_MAC
474476
int dwla_policy;
475477
struct {
476478
uint8_t percent;

0 commit comments

Comments
 (0)