static class LockedVar<A> implements IVar<A> { A v; // you can access this directly if you use one thread transient Lock lock = lock(); *() {} *(A *v) {} public void set(A a) { lock lock; v = a; } public A get() { lock lock; ret v; } public bool has() { lock lock; ret v != null; } public void clear() { lock lock; v = null; } toString { ret str(get()); } }
Began life as a copy of #1003550
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1019343 |
| Snippet name: | class LockedVar - thread-safe variable (same as Var), but using a ReentrantLock |
| Eternal ID of this version: | #1019343/2 |
| Text MD5: | c9a0a7063eaeeeb2855c791aaa01819f |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-11-03 12:59:29 |
| Source code size: | 414 bytes / 18 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 536 / 1087 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |