forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExecutorBridge.swift
121 lines (102 loc) · 4.09 KB
/
ExecutorBridge.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2021 - 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
//
//===----------------------------------------------------------------------===//
//
// Functions to bridge between C++ and Swift. This does not include the
// *Impl functions because we need them separate for Embedded Swift.
//
//===----------------------------------------------------------------------===//
import Swift
@available(SwiftStdlib 6.2, *)
@_silgen_name("_swift_exit")
internal func _exit(result: CInt)
#if !$Embedded
@available(SwiftStdlib 6.2, *)
@_silgen_name("_swift_task_isMainExecutorSwift")
internal func _isMainExecutor<E>(_ executor: E) -> Bool where E: SerialExecutor {
return executor.isMainExecutor
}
#endif
@available(SwiftStdlib 6.2, *)
@_silgen_name("_swift_task_checkIsolatedSwift")
internal func checkIsolated<E>(executor: E) where E: SerialExecutor {
executor.checkIsolated()
}
@available(SwiftStdlib 6.2, *)
@_silgen_name("_swift_task_isIsolatingCurrentContextSwift")
internal func isIsolatingCurrentContext<E>(executor: E) -> Bool
where E: SerialExecutor
{
return executor.isIsolatingCurrentContext()
}
@available(SwiftStdlib 6.2, *)
@_silgen_name("_swift_getActiveExecutor")
internal func _getActiveExecutor() -> UnownedSerialExecutor
@available(SwiftStdlib 6.2, *)
@_silgen_name("_swift_getCurrentTaskExecutor")
internal func _getCurrentTaskExecutor() -> UnownedTaskExecutor
@available(SwiftStdlib 6.2, *)
@_silgen_name("_swift_getPreferredTaskExecutor")
internal func _getPreferredTaskExecutor() -> UnownedTaskExecutor
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_job_allocate")
internal func _jobAllocate(_ job: Builtin.Job,
_ capacity: Int) -> UnsafeMutableRawPointer
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_job_deallocate")
internal func _jobDeallocate(_ job: Builtin.Job,
_ address: UnsafeMutableRawPointer)
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_job_getPriority")
internal func _jobGetPriority(_ job: Builtin.Job) -> UInt8
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_job_getKind")
internal func _jobGetKind(_ job: Builtin.Job) -> UInt8
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_job_getExecutorPrivateData")
internal func _jobGetExecutorPrivateData(
_ job: Builtin.Job
) -> UnsafeMutableRawPointer
#if !$Embedded
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_getMainExecutor")
internal func _getMainExecutor() -> any SerialExecutor {
return MainActor.executor
}
#else
// For task-to-thread model, this is implemented in C++
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_getMainExecutor")
internal func _getMainExecutor() -> any SerialExecutor
#endif // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
#endif // !$Embedded
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_dispatchMain")
internal func _dispatchMain()
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_dispatchEnqueueMain")
internal func _dispatchEnqueueMain(_ job: UnownedJob)
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_dispatchEnqueueGlobal")
internal func _dispatchEnqueueGlobal(_ job: UnownedJob)
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_dispatchEnqueueWithDeadline")
internal func _dispatchEnqueueWithDeadline(_ global: CBool,
_ sec: CLongLong,
_ nsec: CLongLong,
_ tsec: CLongLong,
_ tnsec: CLongLong,
_ clock: CInt,
_ job: UnownedJob)
@available(SwiftStdlib 6.2, *)
@_silgen_name("swift_dispatchAssertMainQueue")
internal func _dispatchAssertMainQueue()