Skip to content

Commit 65cd32e

Browse files
committed
[Concurrency] DispatchSerialQueue does not exist on linux still
1 parent 022ed7a commit 65cd32e

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

include/swift/ABI/Executor.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class SerialExecutorRef {
7777
/// Executor that may need to participate in complex "same context" checks,
7878
/// by invoking `isSameExclusiveExecutionContext` when comparing execution contexts.
7979
ComplexEquality = 0b01,
80-
///
80+
/// Mark this executor as the one used by `Task.startSynchronously`,
81+
/// It cannot participate in switching.
82+
// TODO: Perhaps make this a generic "cannot switch" rather than start synchronously specific.
8183
StartSynchronously = 0b10,
8284
};
8385

stdlib/public/Concurrency/Actor.cpp

+1-17
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ class ExecutorTrackingInfo {
134134
/// is `generic`.
135135
TaskExecutorRef TaskExecutor = TaskExecutorRef::undefined();
136136

137-
bool StartedSynchronouslySkipSwitchOnce = false;
138-
139137
/// Whether this context allows switching. Some contexts do not;
140138
/// for example, we do not allow switching from swift_job_run
141139
/// unless the passed-in executor is generic.
@@ -179,7 +177,7 @@ class ExecutorTrackingInfo {
179177
}
180178

181179
bool allowsSwitching() const {
182-
return AllowsSwitching && !StartedSynchronouslySkipSwitchOnce;
180+
return AllowsSwitching;
183181
}
184182

185183
/// Disallow switching in this tracking context. This should only
@@ -188,16 +186,6 @@ class ExecutorTrackingInfo {
188186
AllowsSwitching = false;
189187
}
190188

191-
void markSynchronousStart() {
192-
StartedSynchronouslySkipSwitchOnce = true;
193-
}
194-
bool isSynchronousStart() const {
195-
return StartedSynchronouslySkipSwitchOnce;
196-
}
197-
void withoutStartSynchronously() {
198-
StartedSynchronouslySkipSwitchOnce = false;
199-
}
200-
201189
static ExecutorTrackingInfo *current() {
202190
return ActiveInfoInThread.get();
203191
}
@@ -2170,10 +2158,6 @@ static bool canGiveUpThreadForSwitch(ExecutorTrackingInfo *trackingInfo,
21702158
// We can certainly "give up" a generic executor to try to run
21712159
// a task for an actor.
21722160
if (currentExecutor.isGeneric()) {
2173-
if (trackingInfo->isSynchronousStart()) {
2174-
return false;
2175-
}
2176-
21772161
if (currentExecutor.isForSynchronousStart()) {
21782162
return false;
21792163
}

stdlib/public/Concurrency/TaskPrivate.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace swift {
4444
#if 0
4545
#define SWIFT_TASK_DEBUG_LOG_ENABLED 1
4646
#define SWIFT_TASK_DEBUG_LOG(fmt, ...) \
47-
fprintf(stdout, "[%#lx] [%s:%d](%s) " fmt "\n", \
47+
fprintf(stderr, "[%#lx] [%s:%d](%s) " fmt "\n", \
4848
(unsigned long)Thread::current().platformThreadId(), __FILE__, \
4949
__LINE__, __FUNCTION__, __VA_ARGS__)
5050
#else

test/Concurrency/Runtime/startSynchronously.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func callActorFromStartSynchronousTask(recipient rec: TargetActorToCall) {
319319

320320
print("\n\n==== ------------------------------------------------------------------")
321321
print("callActorFromStartSynchronousTask() - actor in custom executor with its own queue")
322-
let actorQueue = DispatchSerialQueue(label: "recipient-actor-queue")
322+
let actorQueue = DispatchQueue(label: "recipient-actor-queue")
323323
callActorFromStartSynchronousTask(recipient: .recipientOnQueue(RecipientOnQueue(queue: actorQueue)))
324324

325325
// CHECK-LABEL: callActorFromStartSynchronousTask() - actor in custom executor with its own queue
@@ -367,7 +367,7 @@ actor RecipientOnQueue {
367367
let executor: NaiveQueueExecutor
368368
nonisolated let unownedExecutor: UnownedSerialExecutor
369369

370-
init(queue: DispatchSerialQueue) {
370+
init(queue: DispatchQueue) {
371371
self.executor = NaiveQueueExecutor(queue: queue)
372372
self.unownedExecutor = executor.asUnownedSerialExecutor()
373373
}

0 commit comments

Comments
 (0)