Files
swift-mirror/stdlib/public/Concurrency/ExecutorBridge.h
Alastair Houghton 3d0d0b4328 [Concurrency] Make initial executor construction fully thread safe.
I had originally thought that we'd get away without this because the
executor construction generally happens in the async `main` function,
but of course if a program doesn't already use Swift Concurrency,
and someone uses it from a plug-in or library it loads, there's a
risk that we might have a race condition.

rdar://149346132
2025-04-17 21:48:42 +01:00

51 lines
1.4 KiB
C++

//===--- ExecutorBridge.h - C++ side of executor bridge -------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_EXECUTOR_BRIDGE_H_
#define SWIFT_EXECUTOR_BRIDGE_H_
#include "swift/Runtime/Concurrency.h"
namespace swift {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
extern "C" SWIFT_CC(swift)
SerialExecutorRef swift_getMainExecutor();
#if !SWIFT_CONCURRENCY_EMBEDDED
extern "C" SWIFT_CC(swift)
void *swift_createDispatchEventC(void (*handler)(void *), void *context);
extern "C" SWIFT_CC(swift)
void swift_destroyDispatchEventC(void *event);
extern "C" SWIFT_CC(swift)
void swift_signalDispatchEvent(void *event);
#endif // !SWIFT_CONCURRENCY_EMBEDDED
extern "C" SWIFT_CC(swift) __attribute__((noreturn))
void swift_dispatchMain();
extern "C" SWIFT_CC(swift)
void swift_createDefaultExecutors();
extern "C" SWIFT_CC(swift)
void swift_createDefaultExecutorsOnce();
#pragma clang diagnostic pop
} // namespace swift
#endif /* SWIFT_EXECUTOR_BRIDGE_H_ */