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

47
LINES

< > BotCompany Repo | #1018419 - vmBus_onMessage

JavaX fragment (include)

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   

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

No comments. add comment

Snippet ID: #1018419
Snippet name: vmBus_onMessage
Eternal ID of this version: #1018419/17
Text MD5: f1851af1da30176f31aef915f10ca37d
Author: stefan
Category: javax / vm
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-26 18:08:58
Source code size: 1494 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 262 / 325
Version history: 16 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1018419 & http://1018419.tinybrain.de