We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 381910b commit 86eaa69Copy full SHA for 86eaa69
1 file changed
src/queue.ts
@@ -98,7 +98,7 @@ export class Queue<TIn, TOut> {
98
public constructor(options: QueueOptions<TIn, TOut>) {
99
this.options = options = { ...this.defaultOptions, ...options };
100
101
- if (isMainThread) {
+ if (this.isMainThread()) {
102
this.buildPool()
103
.catch(options.fatal);
104
@@ -116,6 +116,15 @@ export class Queue<TIn, TOut> {
116
}
117
118
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
+
128
/**
129
* Push a new task to the queue to be run in parallel. This task will
130
* not be joined back into the main thread on completion.
0 commit comments