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

51
LINES

< > BotCompany Repo | #1018419 // vmBus_onMessage

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

Libraryless. Click here for Pure Java version (2924L/17K).

1  
static <A> AutoCloseable mapMethodLike vmBus_onMessage(S msg, IVF1<A> onMessage) {
2  
  ret vmBus_onMessage(msg, ivf1ToVF1(onMessage));
3  
}
4  
5  
static <A> AutoCloseable mapMethodLike vmBus_onMessage(fS msg, final VF1<A> onMessage) {
6  
  Map<S, Set> map = vm_busListenersByMessage_live();
7  
  synchronized(map) {
8  
    Set listeners = map.get(msg);
9  
    if (listeners == null) map.put(msg, listeners = syncIdentityHashSet());
10  
    // We're technically violating the one-synchronized-object-per-thread rule,
11  
    // but it should be OK here.
12  
    // TODO: remove empty sets from map
13  
    ret tempAdd(listeners, voidfunc(S _msg, O arg) {
14  
      callF(onMessage, arg)
15  
    });
16  
  }
17  
}
18  
19  
ifclass VF2
20  
static <A, B> AutoCloseable vmBus_onMessage(S msg, final VF2<A, B> onMessage) {
21  
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
22  
    callF(onMessage, first(o), second(o));
23  
  });
24  
}
25  
endif
26  
27  
static <A, B> AutoCloseable vmBus_onMessage(S msg, final IVF2<A, B> onMessage) {
28  
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
29  
    callF(onMessage, first(o), second(o));
30  
  });
31  
}
32  
33  
ifclass VF3
34  
static <A, B, C> AutoCloseable vmBus_onMessage(S msg, final VF3<A, B, C> onMessage) {
35  
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
36  
    callF(onMessage, first(o), second(o), third(o));
37  
  });
38  
}
39  
endif
40  
41  
ifclass VF4
42  
static <A, B, C, D> AutoCloseable vmBus_onMessage(S msg, VF4<A, B, C, D> onMessage) {
43  
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
44  
    callF(onMessage, first(o), second(o), third(o), last(o));
45  
  });
46  
}
47  
endif
48  
49  
static AutoCloseable vmBus_onMessage(S msg, Runnable onMessage) {
50  
  ret vmBus_onMessage(msg, runnableToVF1(onMessage));
51  
}

Author comment

Began life as a copy of #1017923

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018419
Snippet name: vmBus_onMessage
Eternal ID of this version: #1018419/21
Text MD5: db4eac3a3975370be478b3b99e0a946e
Transpilation MD5: 94f500bd86b67960ba2ae2293b1524c2
Author: stefan
Category: javax / vm
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-09 17:54:42
Source code size: 1634 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 627 / 764
Version history: 20 change(s)
Referenced in: [show references]