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

14
LINES

< > BotCompany Repo | #1007379 // lockOrFail - try to acquire a Lock; fail after timeout

JavaX fragment (include)

static void lockOrFail(Lock lock, long timeout) ctex {
  ping();
  vmBus_send locking(lock, thread := currentThread());
  if (!lock.tryLock(timeout, TimeUnit.MILLISECONDS)) {
    S s = "Couldn't acquire lock after " + timeout + " ms.";
    if (lock instanceof ReentrantLock) {
      ReentrantLock l = cast lock;
      s += " Hold count: " + l.getHoldCount() + ", owner: " + call(l, "getOwner");
    }
    fail(s);
  }
  vmBus_send locked(lock, thread := currentThread());
  ping();
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007379
Snippet name: lockOrFail - try to acquire a Lock; fail after timeout
Eternal ID of this version: #1007379/9
Text MD5: b78bbc96662e3929497b88f401750496
Author: stefan
Category: javax / concurrency
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-22 09:08:36
Source code size: 496 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 490 / 529
Version history: 8 change(s)
Referenced in: [show references]