Skip to content

Commit ca1df1e

Browse files
committed
Fix blocking tests deadlocking on low hardwareConcurrency environments
1 parent abbfdfb commit ca1df1e

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

test/barrier.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { assert, assertEquals } from "@std/assert";
22
import { Barrier, move, spawn } from "../src/deno/lib.ts";
3+
import { initRuntime } from "../src/lib/lib.ts";
4+
5+
initRuntime({ maxWorkers: 8 });
36

47
Deno.test("Barrier: Basic Rendezvous (N=3)", async () => {
58
const barrier = new Barrier(3);

test/mutex_sync.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { move, Mutex, spawn } from "../src/deno/lib.ts";
2+
import { initRuntime } from "../src/lib/lib.ts";
3+
4+
initRuntime({ maxWorkers: 2 });
25

36
Deno.test("Mutex sync", async () => {
47
const sharedInt = new Int32Array(

test/rwlock_concurrent_writers.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { assertEquals } from "@std/assert";
22
import { move, RwLock, spawn } from "../src/deno/lib.ts";
3+
import { initRuntime } from "../src/lib/lib.ts";
4+
5+
const THREAD_COUNT = 4;
6+
const INCREMENTS_PER_THREAD = 50;
7+
8+
initRuntime({ maxWorkers: 4 });
39

410
Deno.test("RwLock: Concurrent Writers (Data Integrity Check)", async () => {
511
// 1. Setup Shared Memory
@@ -12,8 +18,6 @@ Deno.test("RwLock: Concurrent Writers (Data Integrity Check)", async () => {
1218
const lock = new RwLock(data);
1319

1420
// 2. Define Configuration
15-
const THREAD_COUNT = 4;
16-
const INCREMENTS_PER_THREAD = 50;
1721
// Total expected value: 200 (fits within Uint8 range of 0-255)
1822

1923
// 3. Define Worker Task

test/semaphore_rate_limiting.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { assertLess } from "@std/assert";
22
import { move, Semaphore, spawn } from "../src/deno/lib.ts";
3+
import { initRuntime } from "../src/lib/lib.ts";
4+
5+
initRuntime({ maxWorkers: 3 });
36

47
Deno.test("Semaphore Rate Limiting (Sync + 'using')", async () => {
58
// Allow 2 threads at once.

0 commit comments

Comments
 (0)