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

26
LINES

< > BotCompany Repo | #1035565 // FastCollabWorker - uses spin-locking

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

Libraryless. Click here for Pure Java version (9246L/52K).

srecord noeq FastCollabWorker(FastCollab collab, int workerIndex) extends Thread {
  volatile gettable long errorCount;
  volatile gettable long spinWaits;
  volatile gettable long workCount;
  volatile gettable Throwable lastError;
  settable PingSource interruptor;
  
  run {
    Runnable work;
    var interruptor = this.interruptor;
    
    while ((work = collab.grabWork(workerIndex)) != collab.DONE) {
      interruptor?.ping();
      try {
        if (work != null) {
          ++workCount;
          work.run();
        } else
          ++spinWaits;
      } catch e {
        ++errorCount;
        lastError = e;
      }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035565
Snippet name: FastCollabWorker - uses spin-locking
Eternal ID of this version: #1035565/5
Text MD5: 439447c1e127755c72c3104f285d3e70
Transpilation MD5: 2196b56eae50a904fe7baea53e0e88e6
Author: stefan
Category: javax / parallelism
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-19 01:02:10
Source code size: 667 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 13 / 41
Version history: 4 change(s)
Referenced in: [show references]