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

12
LINES

< > BotCompany Repo | #1022182 // vmBus_addListener_basic

JavaX fragment (include)

// listener: voidfunc(S, O) or func(S, O)
static <A> AutoCloseable vmBus_addListener_basic(S msg, O listener) {
  Map<S, Set> map = vm_busListenersByMessage_live();
  synchronized(map) {
    Set listeners = map.get(msg);
    if (listeners == null) map.put(msg, listeners = syncIdentityHashSet());
    // We're technically violating the one-synchronized-object-per-thread rule,
    // but it should be OK here.
    // TODO: remove empty sets from map
    ret tempAdd(listeners, listener);
  }
}

Author comment

Began life as a copy of #1018419

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022182
Snippet name: vmBus_addListener_basic
Eternal ID of this version: #1022182/4
Text MD5: 8fa8466c479fb8a5e3b1e9f4ffe77250
Author: stefan
Category: javax / vm
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-10 14:18:06
Source code size: 504 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 284 / 335
Version history: 3 change(s)
Referenced in: [show references]