Commit | Line | Data |
---|---|---|
838898f1 S |
1 | import type { Worker } from 'cluster' |
2 | import type { MessagePort } from 'worker_threads' | |
1a81f8af | 3 | import type { KillBehavior } from './worker/worker-options' |
838898f1 | 4 | |
729c563d | 5 | /** |
3832ad95 | 6 | * Make all properties in T non-readonly. |
729c563d | 7 | */ |
325f50bc S |
8 | export type Draft<T> = { -readonly [P in keyof T]?: T[P] } |
9 | ||
729c563d S |
10 | /** |
11 | * Message object that is passed between worker and main worker. | |
12 | */ | |
838898f1 S |
13 | export interface MessageValue< |
14 | Data = unknown, | |
15 | MainWorker extends Worker | MessagePort | unknown = unknown | |
16 | > { | |
729c563d S |
17 | /** |
18 | * Input data that will be passed to the worker. | |
19 | */ | |
325f50bc | 20 | readonly data?: Data |
729c563d S |
21 | /** |
22 | * ID of the message. | |
23 | */ | |
325f50bc | 24 | readonly id?: number |
729c563d S |
25 | /** |
26 | * Kill code. | |
27 | */ | |
1a81f8af | 28 | readonly kill?: KillBehavior | 1 |
729c563d S |
29 | /** |
30 | * Error. | |
31 | */ | |
325f50bc | 32 | readonly error?: string |
729c563d S |
33 | /** |
34 | * Reference to main worker. | |
35 | * | |
36 | * _Only for internal use_ | |
37 | */ | |
838898f1 | 38 | readonly parent?: MainWorker |
325f50bc | 39 | } |