-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy path_CJavaScriptEventLoop.h
71 lines (56 loc) · 2.82 KB
/
_CJavaScriptEventLoop.h
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
#ifndef _CJavaScriptEventLoop_h
#define _CJavaScriptEventLoop_h
#include <stdalign.h>
#include <stdint.h>
#define SWIFT_CC(CC) SWIFT_CC_##CC
#define SWIFT_CC_swift __attribute__((swiftcall))
#define SWIFT_EXPORT_FROM(LIBRARY) __attribute__((__visibility__("default")))
/// A schedulable unit
/// Note that this type layout is a part of public ABI, so we expect this field layout won't break in the future versions.
/// Current implementation refers the `swift-5.5-RELEASE` implementation.
/// https://github.com/apple/swift/blob/swift-5.5-RELEASE/include/swift/ABI/Task.h#L43-L129
/// This definition is used to retrieve priority value of a job. After custom-executor API will be introduced officially,
/// the job priority API will be provided in the Swift world.
typedef __attribute__((aligned(2 * alignof(void *)))) struct {
void *_Nonnull Metadata;
int32_t RefCounts;
void *_Nullable SchedulerPrivate[2];
uint32_t Flags;
} Job;
/// A hook to take over global enqueuing.
typedef SWIFT_CC(swift) void (*swift_task_enqueueGlobal_original)(
Job *_Nonnull job);
SWIFT_EXPORT_FROM(swift_Concurrency)
extern void *_Nullable swift_task_enqueueGlobal_hook;
/// A hook to take over global enqueuing with delay.
typedef SWIFT_CC(swift) void (*swift_task_enqueueGlobalWithDelay_original)(
unsigned long long delay, Job *_Nonnull job);
SWIFT_EXPORT_FROM(swift_Concurrency)
extern void *_Nullable swift_task_enqueueGlobalWithDelay_hook;
typedef SWIFT_CC(swift) void (*swift_task_enqueueGlobalWithDeadline_original)(
long long sec,
long long nsec,
long long tsec,
long long tnsec,
int clock, Job *_Nonnull job);
SWIFT_EXPORT_FROM(swift_Concurrency)
extern void *_Nullable swift_task_enqueueGlobalWithDeadline_hook;
/// A hook to take over main executor enqueueing.
typedef SWIFT_CC(swift) void (*swift_task_enqueueMainExecutor_original)(
Job *_Nonnull job);
SWIFT_EXPORT_FROM(swift_Concurrency)
extern void *_Nullable swift_task_enqueueMainExecutor_hook;
/// A hook to override the entrypoint to the main runloop used to drive the
/// concurrency runtime and drain the main queue. This function must not return.
/// Note: If the hook is wrapping the original function and the `compatOverride`
/// is passed in, the `original` function pointer must be passed into the
/// compatibility override function as the original function.
typedef SWIFT_CC(swift) void (*swift_task_asyncMainDrainQueue_original)();
typedef SWIFT_CC(swift) void (*swift_task_asyncMainDrainQueue_override)(
swift_task_asyncMainDrainQueue_original _Nullable original);
SWIFT_EXPORT_FROM(swift_Concurrency)
extern void *_Nullable swift_task_asyncMainDrainQueue_hook;
/// MARK: - thread local storage
extern _Thread_local void * _Nullable swjs_thread_local_event_loop;
extern _Thread_local void * _Nullable swjs_thread_local_task_executor_worker;
#endif