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.

static void lock(Lock lock) ctex {
  ping();
  if (lock == null) ret;
  try {
    vmBus_send locking(lock, thread := currentThread());
    lock.lockInterruptibly();
    vmBus_send locked(lock, thread := currentThread());
  } catch (InterruptedException e) {
    O reason = vm_threadInterruptionReasonsMap().get(currentThread());
    print("Locking interrupted! Reason: " + strOr(reason, "Unknown");
    printStackTrace(e);
    rethrow(e);
  }
  // NO call to ping here! Make sure lock is always released.
}

static void lock(Lock lock, S msg) {
  print("Locking: " + msg);
  lock(lock);
}

static void lock(Lock lock, S msg, long timeout) {
  print("Locking: " + msg);
  lockOrFail(lock, timeout);
}

static ReentrantLock lock() {
  ret fairLock();
}

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: 668 / 791
Version history: 13 change(s)
Referenced in: [show references]