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

12
LINES

< > BotCompany Repo | #1024429 // rOnceAtATimeOnly

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

Libraryless. Click here for Pure Java version (1642L/11K).

static Runnable rOnceAtATimeOnly(Runnable r) {
  if (r == null) null;
  new AtomicBool running;
  ret r {
    if (!running.compareAndSet(false, true)) ret;
    try {
      r.run();
    } finally {
      running.set(false);
    }
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024429
Snippet name: rOnceAtATimeOnly
Eternal ID of this version: #1024429/2
Text MD5: 135d6111dc58876ba6d122a861bcc475
Transpilation MD5: 0e115509c714947ff80d3bbc140f1476
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-12 15:39:12
Source code size: 246 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 286 / 392
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)