static AutoCloseable mapMethodLike vmBus_onMessage(S msg, IVF1 onMessage) {
ret vmBus_onMessage(msg, ivf1ToVF1(onMessage));
}
static AutoCloseable mapMethodLike vmBus_onMessage(fS msg, final VF1 onMessage) {
Map 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 AutoCloseable vmBus_onMessage(S msg, final VF2 onMessage) {
ret vmBus_onMessage(msg, voidfunc(O[] o) {
callF(onMessage, first(o), second(o));
});
}
endif
static AutoCloseable vmBus_onMessage(S msg, final IVF2 onMessage) {
ret vmBus_onMessage(msg, voidfunc(O[] o) {
callF(onMessage, first(o), second(o));
});
}
ifclass VF3
static AutoCloseable vmBus_onMessage(S msg, final VF3 onMessage) {
ret vmBus_onMessage(msg, voidfunc(O[] o) {
callF(onMessage, first(o), second(o), third(o));
});
}
endif
ifclass VF4
static AutoCloseable vmBus_onMessage(S msg, VF4 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));
}