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

static <A> AutoCloseable mapMethodLike vmBus_onMessage(S msg, IVF1<A> onMessage) {
  ret vmBus_onMessage(msg, ivf1ToVF1(onMessage));
}

static <A> AutoCloseable mapMethodLike vmBus_onMessage(fS msg, final VF1<A> onMessage) {
  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, voidfunc(S _msg, O arg) {
      callF(onMessage, arg)
    });
  }
}

ifclass VF2
static <A, B> AutoCloseable vmBus_onMessage(S msg, final VF2<A, B> onMessage) {
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
    callF(onMessage, first(o), second(o));
  });
}
endif

static <A, B> AutoCloseable vmBus_onMessage(S msg, final IVF2<A, B> onMessage) {
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
    callF(onMessage, first(o), second(o));
  });
}

ifclass VF3
static <A, B, C> AutoCloseable vmBus_onMessage(S msg, final VF3<A, B, C> onMessage) {
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
    callF(onMessage, first(o), second(o), third(o));
  });
}
endif

ifclass VF4
static <A, B, C, D> AutoCloseable vmBus_onMessage(S msg, VF4<A, B, C, D> onMessage) {
  ret vmBus_onMessage(msg, voidfunc(O[] o) {
    callF(onMessage, first(o), second(o), third(o), last(o));
  });
}
endif

static AutoCloseable vmBus_onMessage(S msg, Runnable onMessage) {
  ret vmBus_onMessage(msg, runnableToVF1(onMessage));
}

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: 625 / 762
Version history: 20 change(s)
Referenced in: [show references]