Skip to content

Commit

Permalink
Added -timeout <ms> option to PinnedVThreads
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Mar 3, 2025
1 parent bca00a5 commit 3d693c8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/other/org/jgroups/tests/PinnedVThreads.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
* @since 5.4.4
*/
public class PinnedVThreads {
protected int cores, pinned;
protected int cores, pinned;
protected long timeout=5000;

public int cores() {return cores;}
public void cores(int cores) {this.cores=cores;}
public int pinned() {return pinned;}
public void pinned(int pinned) {this.pinned=pinned;}
public long timeout() {return timeout;}
public void timeout(long t) {timeout=t;}


public void start() throws IOException, InterruptedException {
int available_cores=Runtime.getRuntime().availableProcessors();
Expand Down Expand Up @@ -63,7 +67,7 @@ public void start() throws IOException, InterruptedException {
t.start();
}

Util.waitUntilTrue(6_000, 500, () -> count.get() == pinned);
Util.waitUntilTrue(timeout, 500, () -> count.get() == pinned);
if(count.get() == pinned)
System.out.printf("\n** SUCCESS: %d worker threads completed (expected: %d)\n", count.get(), pinned);
else
Expand All @@ -89,7 +93,12 @@ public static void main(String[] args) throws Exception {
test.pinned(Integer.parseInt(args[++i]));
continue;
}
System.out.printf("%s [-cores <number of cores>] [-pinned <number of virtual threads pinned> ]\n",
if("-timeout".equals(args[i])) {
test.timeout(Long.parseLong(args[++i]));
continue;
}
System.out.printf("%s [-cores <number of cores>] [-pinned <number of virtual threads pinned>] " +
"[-timeout <msecs>]\n",
PinnedVThreads.class.getSimpleName());
return;
}
Expand Down

0 comments on commit 3d693c8

Please sign in to comment.