Skip to content

Commit 6285226

Browse files
committed
Remove dead code with task nearest deadline logic
Radar-Id: rdar://problem/88093007
1 parent 17b1ada commit 6285226

File tree

6 files changed

+0
-122
lines changed

6 files changed

+0
-122
lines changed

include/swift/ABI/MetadataValues.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,8 +2343,6 @@ class JobFlags : public FlagSet<uint32_t> {
23432343

23442344
/// Kinds of task status record.
23452345
enum class TaskStatusRecordKind : uint8_t {
2346-
/// A DeadlineStatusRecord, which represents an active deadline.
2347-
Deadline = 0,
23482346

23492347
/// A ChildTaskStatusRecord, which represents the potential for
23502348
/// active child tasks.

include/swift/ABI/TaskStatus.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -79,38 +79,6 @@ class TaskStatusRecord {
7979
void spliceParent(TaskStatusRecord *newParent) { Parent = newParent; }
8080
};
8181

82-
/// A deadline for the task. If this is reached, the task will be
83-
/// automatically cancelled. The deadline can also be queried and used
84-
/// in other ways.
85-
struct TaskDeadline {
86-
// FIXME: I don't really know what this should look like right now.
87-
// It's probably target-specific.
88-
uint64_t Value;
89-
90-
bool operator==(const TaskDeadline &other) const {
91-
return Value == other.Value;
92-
}
93-
bool operator<(const TaskDeadline &other) const {
94-
return Value < other.Value;
95-
}
96-
};
97-
98-
/// A status record which states that there's an active deadline
99-
/// within the task.
100-
class DeadlineStatusRecord : public TaskStatusRecord {
101-
TaskDeadline Deadline;
102-
103-
public:
104-
DeadlineStatusRecord(TaskDeadline deadline)
105-
: TaskStatusRecord(TaskStatusRecordKind::Deadline), Deadline(deadline) {}
106-
107-
TaskDeadline getDeadline() const { return Deadline; }
108-
109-
static bool classof(const TaskStatusRecord *record) {
110-
return record->getKind() == TaskStatusRecordKind::Deadline;
111-
}
112-
};
113-
11482
/// A status record which states that a task has one or
11583
/// more active child tasks.
11684
class ChildTaskStatusRecord : public TaskStatusRecord {

include/swift/Runtime/Concurrency.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -643,31 +643,6 @@ void swift_task_localValuePop();
643643
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
644644
void swift_task_localsCopyTo(AsyncTask* target);
645645

646-
/// This should have the same representation as an enum like this:
647-
/// enum NearestTaskDeadline {
648-
/// case none
649-
/// case alreadyCancelled
650-
/// case active(TaskDeadline)
651-
/// }
652-
/// TODO: decide what this interface should really be.
653-
struct NearestTaskDeadline {
654-
enum Kind : uint8_t {
655-
None,
656-
AlreadyCancelled,
657-
Active
658-
};
659-
660-
TaskDeadline Value;
661-
Kind ValueKind;
662-
};
663-
664-
/// Returns the nearest deadline that's been registered with this task.
665-
///
666-
/// This must be called synchronously with the task.
667-
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
668-
NearestTaskDeadline
669-
swift_task_getNearestDeadline(AsyncTask *task);
670-
671646
/// Switch the current task to a new executor if we aren't already
672647
/// running on a compatible executor.
673648
///

stdlib/public/CompatibilityOverride/CompatibilityOverrideConcurrency.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,6 @@ OVERRIDE_TASK_STATUS(task_escalate, JobPriority,
373373
swift::, (AsyncTask *task, JobPriority newPriority),
374374
(task, newPriority))
375375

376-
OVERRIDE_TASK_STATUS(task_getNearestDeadline, NearestTaskDeadline,
377-
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swift),
378-
swift::, (AsyncTask *task), (task))
379-
380376
#undef OVERRIDE
381377
#undef OVERRIDE_ACTOR
382378
#undef OVERRIDE_TASK

stdlib/public/Concurrency/TaskStatus.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,6 @@ void swift::_swift_taskGroup_detachChild(TaskGroup *group,
423423
/// Perform any cancellation actions required by the given record.
424424
static void performCancellationAction(TaskStatusRecord *record) {
425425
switch (record->getKind()) {
426-
// Deadlines don't require any special support.
427-
case TaskStatusRecordKind::Deadline:
428-
return;
429-
430426
// Child tasks need to be recursively cancelled.
431427
case TaskStatusRecordKind::ChildTask: {
432428
auto childRecord = cast<ChildTaskStatusRecord>(record);
@@ -518,10 +514,6 @@ static void swift_task_cancelImpl(AsyncTask *task) {
518514
static void performEscalationAction(TaskStatusRecord *record,
519515
JobPriority newPriority) {
520516
switch (record->getKind()) {
521-
// Deadlines don't require any special support.
522-
case TaskStatusRecordKind::Deadline:
523-
return;
524-
525517
// Child tasks need to be recursively escalated.
526518
case TaskStatusRecordKind::ChildTask: {
527519
auto childRecord = cast<ChildTaskStatusRecord>(record);
@@ -634,52 +626,5 @@ static swift_task_escalateImpl(AsyncTask *task, JobPriority newPriority) {
634626
return newStatus.getStoredPriority();
635627
}
636628

637-
/**************************************************************************/
638-
/******************************** DEADLINE ********************************/
639-
/**************************************************************************/
640-
SWIFT_CC(swift)
641-
static NearestTaskDeadline swift_task_getNearestDeadlineImpl(AsyncTask *task) {
642-
// We don't have to worry about the deadline records being
643-
// concurrently modified, so we can just walk the record chain,
644-
// ignoring the possibility of a concurrent cancelling task.
645-
646-
// Load the current state.
647-
auto &status = task->_private()._status();
648-
auto oldStatus = status.load(std::memory_order_relaxed);
649-
650-
NearestTaskDeadline result;
651-
652-
// If it's already cancelled, we're done.
653-
if (oldStatus.isCancelled()) {
654-
result.ValueKind = NearestTaskDeadline::AlreadyCancelled;
655-
return result;
656-
}
657-
658-
// If it's locked, wait for the lock; we can't safely step through
659-
// the RecordLockStatusRecord on a different thread.
660-
if (oldStatus.isStatusRecordLocked()) {
661-
waitForStatusRecordUnlock(task, oldStatus);
662-
assert(!oldStatus.isStatusRecordLocked());
663-
}
664-
665-
// Walk all the records looking for deadlines.
666-
result.ValueKind = NearestTaskDeadline::None;
667-
for (const auto *record: oldStatus.records()) {
668-
auto deadlineRecord = dyn_cast<DeadlineStatusRecord>(record);
669-
if (!deadlineRecord) continue;
670-
auto recordDeadline = deadlineRecord->getDeadline();
671-
672-
// If we already have a deadline, pick the earlier.
673-
if (result.ValueKind == NearestTaskDeadline::Active) {
674-
if (recordDeadline < result.Value)
675-
result.Value = recordDeadline;
676-
} else {
677-
result.Value = recordDeadline;
678-
result.ValueKind = NearestTaskDeadline::Active;
679-
}
680-
}
681-
return result;
682-
}
683-
684629
#define OVERRIDE_TASK_STATUS COMPATIBILITY_OVERRIDE
685630
#include COMPATIBILITY_OVERRIDE_INCLUDE_PATH

unittests/runtime/CompatibilityOverrideConcurrency.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,4 @@ TEST_F(CompatibilityOverrideConcurrencyTest, test_swift_task_escalate) {
255255
swift_task_escalate(nullptr, {});
256256
}
257257

258-
TEST_F(CompatibilityOverrideConcurrencyTest, test_swift_task_getNearestDeadline) {
259-
swift_task_getNearestDeadline(nullptr);
260-
}
261-
262258
#endif

0 commit comments

Comments
 (0)