-
Notifications
You must be signed in to change notification settings - Fork 0
/
threadily.d.ts
86 lines (84 loc) · 3 KB
/
threadily.d.ts
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
// When exporting Threadily to javascript using Emscripten, this definition file defines all the outputted types from Threadily
declare module "threadily" {
// Observable.cpp
export interface ISubscribeHandle {
}
export interface ObservableCallback<T> {
onChange(T): void;
implement: any;
}
export interface Observable<T> {
get(): T;
set(newValue: T): void;
subscribe(callback: ObservableCallback<T>): ISubscribeHandle;
unsubscribe(handle: ISubscribeHandle): void;
}
export enum ObservableActionType {
Insert = 0,
Erase = 1,
Set = 2,
}
export interface ObservableVectorCallback<T> {
onChange(newValue: T): void;
implement: any;
}
export interface ObservableVector<T> {
size(): number;
at(index: number): T;
insert(index: number, value: T): void;
set(index: number, value: T): void;
erase(index: number): void;
subscribe(callback: ObservableVectorCallback<T>, index: number, action: ObservableActionType): ISubscribeHandle;
unsubscribe(handle: ISubscribeHandle): void;
}
// ThreadManager.cpp
export interface VectorUnsignedInt {
new(): VectorUnsignedInt;
push_back(value: number): void;
}
export interface IThreadManager {
clear(): void;
}
export interface ThreadManager extends IThreadManager {
new(): ThreadManager;
// TODO: Replace any with an actual definition
getOrCreateThread(threadId: number, notifiesThreadIds: VectorUnsignedInt, runner: any): any;
}
// ThreadObject.cpp
export interface IThreadObject {
getThreadId: () => number;
getInstanceId: () => IThreadObjectId;
clone<T>(): T;
delete: () => void;
isDeleted: () => boolean;
}
export interface ThreadObject<T extends IThreadObjectId> extends IThreadObject {
getId: () => T;
}
export interface ThreadObject_ThreadObjectId extends ThreadObject<ThreadObjectId> {
}
// ThreadObjectId.cpp
export interface IThreadObjectId {
}
export interface ThreadObjectId {
instanceId: number;
}
// ThreadObjectManager.cpp
export interface IThreadObjectManager {
getThreadManager(): IThreadManager;
}
export interface ThreadObjectManager<T> extends IThreadObjectManager {
new(threadManager: ThreadManager);
getOrCreateObject(threadId: number, id: IThreadObjectId): T;
}
// ThreadQueueItem.cpp - Ignored as it's used internally
// ThreadQueueItemHandler.cpp - Ignored as it's used internally
// ThreadQueueItemManager.cpp - Ignored as it's used internally
export interface Threadily {
ThreadManager: ThreadManager;
VectorUnsignedInt: VectorUnsignedInt;
ISubscribeHandleBoolCallback: ObservableCallback<boolean>;
ISubscribeHandleWStringCallback: ObservableCallback<string>;
ISubscribeHandleWStringVectorCallback: ObservableVectorCallback<string>;
}
}