Skip to content

Commit f2205f7

Browse files
committed
try with busy workers again
1 parent 7943f4d commit f2205f7

File tree

3 files changed

+41
-30
lines changed

3 files changed

+41
-30
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [macos-latest, ubuntu-latest, windows-latest]
14-
target: [jvm, cpp]
14+
target: [jvm, cpp, hl]
1515
exclude:
1616
# php is not available by default for macos runners, probably not worth bothering
1717
- os: macos-latest

src/hxcoro/CoroRun.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class CoroRun {
122122
}
123123
}
124124

125-
#elseif (jvm || cpp)
125+
#elseif (jvm || cpp || hl)
126126

127127
static public function runWith<T>(context:Context, lambda:NodeLambda<T>):T {
128128
final scheduler = new EventLoopScheduler();

src/hxcoro/thread/FixedThreadPool.hx

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -237,37 +237,48 @@ private class Worker {
237237
inShutdown = false;
238238
continue;
239239
}
240-
// If we did nothing, wait for the condition variable.
241-
if (cond.tryAcquire()) {
242-
if (shutdownCallback != null) {
243-
if (inShutdown) {
244-
--activity.activeWorkers;
245-
--activity.availableWorkers;
246-
cond.broadcast();
247-
cond.release();
248-
break;
249-
} else {
250-
inShutdown = true;
251-
cond.broadcast();
252-
cond.release();
253-
continue;
254-
}
255-
}
256-
if (activity.activeWorkers == 1) {
257-
cond.broadcast();
258-
cond.release();
240+
if (shutdownCallback != null) {
241+
if (inShutdown) {
242+
break;
243+
} else {
244+
inShutdown = true;
245+
BackOff.backOff();
259246
continue;
260247
}
261-
// These modifications are fine because we hold onto the cond mutex.
262-
--activity.activeWorkers;
263-
state = Waiting;
264-
cond.wait();
265-
state = CheckingQueues;
266-
++activity.activeWorkers;
267-
cond.release();
268-
} else {
269-
BackOff.backOff();
270248
}
249+
BackOff.backOff();
250+
251+
// If we did nothing, wait for the condition variable.
252+
// if (cond.tryAcquire()) {
253+
// if (shutdownCallback != null) {
254+
// if (inShutdown) {
255+
// --activity.activeWorkers;
256+
// --activity.availableWorkers;
257+
// cond.broadcast();
258+
// cond.release();
259+
// break;
260+
// } else {
261+
// inShutdown = true;
262+
// cond.broadcast();
263+
// cond.release();
264+
// continue;
265+
// }
266+
// }
267+
// if (activity.activeWorkers == 1) {
268+
// cond.broadcast();
269+
// cond.release();
270+
// continue;
271+
// }
272+
// // These modifications are fine because we hold onto the cond mutex.
273+
// --activity.activeWorkers;
274+
// state = Waiting;
275+
// cond.wait();
276+
// state = CheckingQueues;
277+
// ++activity.activeWorkers;
278+
// cond.release();
279+
// } else {
280+
// BackOff.backOff();
281+
// }
271282
}
272283
}
273284

0 commit comments

Comments
 (0)