Skip to content

Commit d3a2530

Browse files
Revert some changes for cleaner diff
1 parent 74d25eb commit d3a2530

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,13 +1086,9 @@ class DefaultActorImpl
10861086
/// new priority
10871087
void enqueueStealer(Job *job, JobPriority priority);
10881088

1089-
/// Dequeues one job from `prioritisedJobs`.
1090-
/// The calling thread must be holding the actor lock while calling this
1089+
/// Processes incoming jobs if needed and dequeues one job of the highest priority.
1090+
/// The calling thread must be holding the actor lock while calling this.
10911091
Job *drainOne();
1092-
1093-
/// Atomically claims incoming jobs from ActiveActorStatus, and calls `handleUnprioritizedJobs()`.
1094-
/// Called with actor lock held on current thread.
1095-
void processIncomingQueue();
10961092
#endif
10971093

10981094
/// Check if the actor is actually a distributed *remote* actor.
@@ -1129,6 +1125,10 @@ class DefaultActorImpl
11291125
/// when actor gets a priority override and we schedule a stealer.
11301126
void scheduleActorProcessJob(JobPriority priority);
11311127

1128+
/// Atomically claims incoming jobs from ActiveActorStatus, and calls `handleUnprioritizedJobs()`.
1129+
/// Called with actor lock held on current thread.
1130+
void processIncomingQueue();
1131+
11321132
/// Processes claimed incoming jobs into `prioritisedJobs`.
11331133
/// Incoming jobs are of mixed priorities and in LIFO order.
11341134
/// Called with actor lock held on current thread.
@@ -1435,6 +1435,7 @@ void DefaultActorImpl::handleUnprioritizedJobs(Job *head) {
14351435
Job *DefaultActorImpl::drainOne() {
14361436
SWIFT_TASK_DEBUG_LOG("Draining one job from default actor %p", this);
14371437

1438+
processIncomingQueue();
14381439
traceJobQueue(this, prioritisedJobs.peek());
14391440
auto firstJob = prioritisedJobs.dequeue();
14401441
if (!firstJob) {
@@ -1499,40 +1500,39 @@ static void defaultActorDrain(DefaultActorImpl *actor) {
14991500
TaskExecutorRef::undefined());
15001501

15011502
while (true) {
1503+
if (shouldYieldThread()) {
1504+
currentActor->unlock(true);
1505+
break;
1506+
}
1507+
15021508
Job *job = currentActor->drainOne();
15031509
if (job == NULL) {
15041510
// No work left to do, try unlocking the actor. This may fail if there is
15051511
// work concurrently enqueued in which case, we'd try again in the loop
1506-
if (currentActor->unlock(false)) {
1507-
break;
1508-
}
1509-
} else {
1510-
if (AsyncTask *task = dyn_cast<AsyncTask>(job)) {
1511-
auto taskExecutor = task->getPreferredTaskExecutor();
1512-
trackingInfo.setTaskExecutor(taskExecutor);
1512+
if (!currentActor->unlock(false)) {
1513+
continue;
15131514
}
1515+
break;
1516+
}
15141517

1515-
// This thread is now going to follow the task on this actor. It may hop off
1516-
// the actor
1517-
runJobInEstablishedExecutorContext(job);
1518-
1519-
// We could have come back from the job on a generic executor and not as
1520-
// part of a default actor. If so, there is no more work left for us to do
1521-
// here.
1522-
auto currentExecutor = trackingInfo.getActiveExecutor();
1523-
if (!currentExecutor.isDefaultActor()) {
1524-
currentActor = nullptr;
1525-
break;
1526-
}
1527-
currentActor = asImpl(currentExecutor.getDefaultActor());
1518+
if (AsyncTask *task = dyn_cast<AsyncTask>(job)) {
1519+
auto taskExecutor = task->getPreferredTaskExecutor();
1520+
trackingInfo.setTaskExecutor(taskExecutor);
15281521
}
15291522

1530-
if (shouldYieldThread()) {
1531-
currentActor->unlock(true);
1523+
// This thread is now going to follow the task on this actor. It may hop off
1524+
// the actor
1525+
runJobInEstablishedExecutorContext(job);
1526+
1527+
// We could have come back from the job on a generic executor and not as
1528+
// part of a default actor. If so, there is no more work left for us to do
1529+
// here.
1530+
auto currentExecutor = trackingInfo.getActiveExecutor();
1531+
if (!currentExecutor.isDefaultActor()) {
1532+
currentActor = nullptr;
15321533
break;
15331534
}
1534-
1535-
currentActor->processIncomingQueue();
1535+
currentActor = asImpl(currentExecutor.getDefaultActor());
15361536
}
15371537

15381538
// Leave the tracking info.

0 commit comments

Comments
 (0)