Skip to content

Commit 86eaa69

Browse files
committed
Add Queue.isMainThread()
1 parent 381910b commit 86eaa69

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/queue.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class Queue<TIn, TOut> {
9898
public constructor(options: QueueOptions<TIn, TOut>) {
9999
this.options = options = { ...this.defaultOptions, ...options };
100100

101-
if (isMainThread) {
101+
if (this.isMainThread()) {
102102
this.buildPool()
103103
.catch(options.fatal);
104104

@@ -116,6 +116,15 @@ export class Queue<TIn, TOut> {
116116
}
117117
}
118118

119+
/**
120+
* Check if this thread is the main thread
121+
*
122+
* @returns Returns true on the main thread, false on workers
123+
*/
124+
public isMainThread(): boolean {
125+
return isMainThread;
126+
}
127+
119128
/**
120129
* Push a new task to the queue to be run in parallel. This task will
121130
* not be joined back into the main thread on completion.

0 commit comments

Comments
 (0)