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).

1  
static Runnable rOnceAtATimeOnly(Runnable r) {
2  
  if (r == null) null;
3  
  new AtomicBool running;
4  
  ret r {
5  
    if (!running.compareAndSet(false, true)) ret;
6  
    try {
7  
      r.run();
8  
    } finally {
9  
      running.set(false);
10  
    }
11  
  };
12  
}

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: 285 / 391
Version history: 1 change(s)
Referenced in: [show references]