forked from kherud/java-llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCancellationTokenRace.java
More file actions
34 lines (29 loc) · 1.16 KB
/
Copy pathCancellationTokenRace.java
File metadata and controls
34 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
//
// SPDX-License-Identifier: MIT
package net.ladenthin.llama.jcstress;
import net.ladenthin.llama.CancellationToken;
import org.openjdk.jcstress.annotations.Actor;
import org.openjdk.jcstress.annotations.Arbiter;
import org.openjdk.jcstress.annotations.Description;
import org.openjdk.jcstress.annotations.Expect;
import org.openjdk.jcstress.annotations.JCStressTest;
import org.openjdk.jcstress.annotations.Outcome;
import org.openjdk.jcstress.annotations.State;
import org.openjdk.jcstress.infra.results.Z_Result;
@JCStressTest
@Description("cancel() must be visible to the arbiter via the volatile flag.")
@Outcome(id = "true", expect = Expect.ACCEPTABLE, desc = "Cancellation visible after actor completes")
@Outcome(id = "false", expect = Expect.FORBIDDEN, desc = "BUG: volatile write not seen after actor finish")
@State
public class CancellationTokenRace {
private final CancellationToken token = new CancellationToken();
@Actor
public void writer() {
token.cancel();
}
@Arbiter
public void check(Z_Result r) {
r.r1 = token.isCancelled();
}
}