1
1
/* eslint-disable @typescript-eslint/no-empty-function */
2
2
/* eslint-disable @typescript-eslint/no-unused-vars */
3
+ import { defaultThreadPoolSettings , TaskType } from '../../../src/core/constants.js'
4
+ import { Task } from '../../../src/core/task.js'
5
+ import { Thread } from '../../../src/core/thread.js'
6
+ import { ThreadPool } from '../../../src/core/thread_pool.js'
3
7
import { WorkerBase } from '../../../src/core/worker_base.js'
4
8
5
9
import type { Coroutine } from '../../../src/core/coroutine.js'
6
- import type { Thread } from '../../../src/core/thread.js'
7
10
import type {
8
11
IWorker ,
9
12
WorkerMessageHandler ,
@@ -12,11 +15,17 @@ import type {
12
15
IWorkerFactory ,
13
16
InstantiateObjectData
14
17
} from '../../../src/core/types.js'
15
- import { defaultThreadPoolSettings , TaskType } from '../../../src/core/constants.js'
16
- import { Task } from '../../../src/core/task.js'
17
- import { ThreadPool } from '../../../src/core/thread_pool.js'
18
18
import type { ThreadPoolSettings } from '../../../src/index.js'
19
19
20
+ export function sleep ( seconds : number | undefined = 0 ) {
21
+ return new Promise ( resolve => {
22
+ const timer = setTimeout ( ( ) => {
23
+ clearInterval ( timer )
24
+ resolve ( true )
25
+ } , seconds * 1000 )
26
+ } )
27
+ }
28
+
20
29
export function createSampleValueDict ( ) : Dict < unknown > {
21
30
return {
22
31
undefined : undefined ,
@@ -60,6 +69,10 @@ export function createWorker() {
60
69
} )
61
70
}
62
71
72
+ export function createThread ( ) {
73
+ return new Thread ( createWorkerFactory ( ) )
74
+ }
75
+
63
76
export function createInstantiateObjectTask ( ) {
64
77
const taskType = TaskType . InstantiateObject
65
78
const taskData : InstantiateObjectData = [ 'moduleSrc' , 'exportName' , [ ] ]
0 commit comments