Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1007380 - lock - acquire Lock with message; also lock() is a synonym of fairLock()

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (2539L) is out of date.

1  
static void lock(Lock lock) ctex {
2  
  ping();
3  
  if (lock == null) ret;
4  
  try {
5  
    vmBus_send locking(lock, thread := currentThread());
6  
    lock.lockInterruptibly();
7  
    vmBus_send locked(lock, thread := currentThread());
8  
  } catch (InterruptedException e) {
9  
    O reason = vm_threadInterruptionReasonsMap().get(currentThread());
10  
    print("Locking interrupted! Reason: " + strOr(reason, "Unknown");
11  
    printStackTrace(e);
12  
    rethrow(e);
13  
  }
14  
  // NO call to ping here! Make sure lock is always released.
15  
}
16  
17  
static void lock(Lock lock, S msg) {
18  
  print("Locking: " + msg);
19  
  lock(lock);
20  
}
21  
22  
static void lock(Lock lock, S msg, long timeout) {
23  
  print("Locking: " + msg);
24  
  lockOrFail(lock, timeout);
25  
}
26  
27  
static ReentrantLock lock() {
28  
  ret fairLock();
29  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1007380
Snippet name: lock - acquire Lock with message; also lock() is a synonym of fairLock()
Eternal ID of this version: #1007380/14
Text MD5: dfd9fd483a2f2c292514fa3e2db4ba21
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-22 09:08:43
Source code size: 778 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 482 / 568
Version history: 13 change(s)
Referenced in: [show references]