Libraryless. Click here for Pure Java version (112L/1K).
sclass FasterFlag is Runnable { private volatile boolean up; /** returns true if flag was down before (i.e. flag was actually raised right now) */ public bool raise() { if (up) false; synchronized { if (up) false; up = true; notifyAll(); true; } } run { raise(); } public void waitUntilUp() ctex { if (up) ret; synchronized { while (!up) wait(); } } public bool waitUntilUp(double timeout) { if (timeout == infinity()) { waitUntilUp(); ret isUp(); } else ret waitUntilUp(toMS(timeout)); } public bool waitUntilUp(long timeout) ctex { if (up) ret true; synchronized { if (!up) wait(timeout); } ret isUp(); } public bool isUp aka get() { ret up; } toString { ret isUp() ? "up" : "down"; } }
Began life as a copy of #1000915
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035583 |
Snippet name: | FasterFlag - Flag using double-checked locking (now merged into Flag) |
Eternal ID of this version: | #1035583/4 |
Text MD5: | 9cb52b784b350ceb7685e19fe5c6b6a3 |
Transpilation MD5: | 723c32b1803240b6fe871ecaf4b617cc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-20 21:37:13 |
Source code size: | 878 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 126 / 192 |
Version history: | 3 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |