Skip to content

Commit 5882e03

Browse files
authored
Merge pull request #38819 from etcwilde/ewilde/remove-runAsyncAndBlock-internals
Remove run async and block internals
2 parents 29e26eb + 1906350 commit 5882e03

File tree

5 files changed

+0
-328
lines changed

5 files changed

+0
-328
lines changed

include/swift/Runtime/Concurrency.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -618,19 +618,6 @@ SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
618618
NearestTaskDeadline
619619
swift_task_getNearestDeadline(AsyncTask *task);
620620

621-
/// Run the given async function and block the current thread until
622-
/// it returns. This is a hack added for testing purposes; eventually
623-
/// top-level code will be an async context, and the need for this in
624-
/// tests should go away. We *definitely* do not want this to be part
625-
/// of the standard feature set.
626-
///
627-
/// The argument is a `() async -> ()` function, whose ABI is currently
628-
/// quite complex. Eventually this should use a different convention;
629-
/// that's rdar://72105841.
630-
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
631-
void swift_task_runAndBlockThread(const void *function,
632-
HeapObject *functionContext);
633-
634621
/// Switch the current task to a new executor if we aren't already
635622
/// running on a compatible executor.
636623
///

stdlib/public/Concurrency/AsyncCall.h

Lines changed: 0 additions & 192 deletions
This file was deleted.

stdlib/public/Concurrency/AsyncLet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "swift/Runtime/HeapObject.h"
2525
#include "llvm/ADT/PointerIntPair.h"
2626
#include "TaskPrivate.h"
27-
#include "AsyncCall.h"
2827
#include "Debug.h"
2928

3029
#if !defined(_WIN32)

stdlib/public/Concurrency/Task.cpp

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "swift/Runtime/HeapObject.h"
2525
#include "TaskGroupPrivate.h"
2626
#include "TaskPrivate.h"
27-
#include "AsyncCall.h"
2827
#include "Debug.h"
2928
#include "Error.h"
3029

@@ -857,126 +856,6 @@ void swift_task_future_wait_throwingImpl(
857856
}
858857
}
859858

860-
namespace {
861-
862-
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
863-
864-
class RunAndBlockSemaphore {
865-
bool Finished = false;
866-
public:
867-
void wait() {
868-
donateThreadToGlobalExecutorUntil([](void *context) {
869-
return *reinterpret_cast<bool*>(context);
870-
}, &Finished);
871-
872-
assert(Finished && "ran out of tasks before we were signalled");
873-
}
874-
875-
void signal() {
876-
Finished = true;
877-
}
878-
};
879-
880-
#else
881-
882-
class RunAndBlockSemaphore {
883-
ConditionVariable Queue;
884-
ConditionVariable::Mutex Lock;
885-
bool Finished = false;
886-
public:
887-
/// Wait for a signal.
888-
void wait() {
889-
Lock.withLockOrWait(Queue, [&] {
890-
return Finished;
891-
});
892-
}
893-
894-
void signal() {
895-
Lock.withLockThenNotifyAll(Queue, [&]{
896-
Finished = true;
897-
});
898-
}
899-
};
900-
901-
#endif
902-
903-
using RunAndBlockSignature =
904-
AsyncSignature<void(HeapObject*), /*throws*/ false>;
905-
struct RunAndBlockContext: AsyncContext {
906-
const void *Function;
907-
HeapObject *FunctionContext;
908-
RunAndBlockSemaphore *Semaphore;
909-
};
910-
using RunAndBlockCalleeContext =
911-
AsyncCalleeContext<RunAndBlockContext, RunAndBlockSignature>;
912-
913-
} // end anonymous namespace
914-
915-
/// Second half of the runAndBlock async function.
916-
SWIFT_CC(swiftasync)
917-
static void runAndBlock_finish(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
918-
auto calleeContext = static_cast<RunAndBlockCalleeContext*>(_context);
919-
920-
auto context = popAsyncContext(calleeContext);
921-
922-
context->Semaphore->signal();
923-
924-
return context->ResumeParent(context);
925-
}
926-
927-
/// First half of the runAndBlock async function.
928-
SWIFT_CC(swiftasync)
929-
static void runAndBlock_start(SWIFT_ASYNC_CONTEXT AsyncContext *_context,
930-
SWIFT_CONTEXT HeapObject *closureContext) {
931-
auto callerContext = static_cast<RunAndBlockContext*>(_context);
932-
933-
RunAndBlockSignature::FunctionType *function;
934-
size_t calleeContextSize;
935-
auto functionContext = callerContext->FunctionContext;
936-
assert(closureContext == functionContext);
937-
std::tie(function, calleeContextSize)
938-
= getAsyncClosureEntryPointAndContextSize<
939-
RunAndBlockSignature,
940-
SpecialPointerAuthDiscriminators::AsyncRunAndBlockFunction
941-
>(const_cast<void*>(callerContext->Function), functionContext);
942-
943-
auto calleeContext =
944-
pushAsyncContext<RunAndBlockSignature>(callerContext,
945-
calleeContextSize,
946-
&runAndBlock_finish,
947-
functionContext);
948-
return reinterpret_cast<AsyncVoidClosureEntryPoint *>(function)(
949-
calleeContext, functionContext);
950-
}
951-
952-
// TODO: Remove this hack.
953-
void swift::swift_task_runAndBlockThread(const void *function,
954-
HeapObject *functionContext) {
955-
RunAndBlockSemaphore semaphore;
956-
957-
// Set up a task that runs the runAndBlock async function above.
958-
auto flags = TaskCreateFlags();
959-
flags.setPriority(JobPriority::Default);
960-
auto pair = swift_task_create_common(
961-
flags.getOpaqueValue(),
962-
/*options=*/nullptr,
963-
/*futureResultType=*/nullptr,
964-
reinterpret_cast<ThinNullaryAsyncSignature::FunctionType *>(
965-
&runAndBlock_start),
966-
nullptr,
967-
sizeof(RunAndBlockContext));
968-
auto context = static_cast<RunAndBlockContext*>(pair.InitialContext);
969-
context->Function = function;
970-
context->FunctionContext = functionContext;
971-
context->Semaphore = &semaphore;
972-
973-
// Enqueue the task.
974-
swift_task_enqueueGlobal(pair.Task);
975-
976-
// Wait until the task completes.
977-
semaphore.wait();
978-
}
979-
980859
size_t swift::swift_task_getJobFlags(AsyncTask *task) {
981860
return task->Flags.getOpaqueValue();
982861
}

stdlib/public/Concurrency/TaskGroup.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "swift/Runtime/Config.h"
2929
#include "swift/Runtime/Mutex.h"
3030
#include "swift/Runtime/HeapObject.h"
31-
#include "AsyncCall.h"
3231
#include "Debug.h"
3332
#include "bitset"
3433
#include "string"

0 commit comments

Comments
 (0)