Libraryless. Click here for Pure Java version (2894L/17K).
static <A> O vmBus_onMessage_withLivelinessCheck(bool verbose default false, IF0<Bool> livelinessCheck, S msg, IVF1<A> onMessage) { // Do this BEFORE synchronizing on the map! VMBusListenerWithLivelinessCheck listener = new(null, livelinessCheck, (_msg, arg) -> onMessage.get((A) arg)); listener.verbose = verbose; Map<S, Set> map = vm_busListenersByMessage_live(); synchronized(map) { Set listeners = map.get(msg); if (listeners == null) map.put(msg, listeners = syncIdentityHashSet()); listener.listeners = listeners; // We're technically violating the one-synchronized-object-per-thread rule, // but it should be OK here. listeners.add(listener); ret listener; } }
Began life as a copy of #1031570
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031573 |
Snippet name: | vmBus_onMessage_withLivelinessCheck - performs a custom liveliness check before every invocation and drops listener if check fails |
Eternal ID of this version: | #1031573/8 |
Text MD5: | b4a78691f074e4c641f42c5270d8bc6e |
Transpilation MD5: | 9587310f9bc71f7abe30a28ac4eb5786 |
Author: | stefan |
Category: | javax / vm |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-25 01:41:08 |
Source code size: | 725 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 172 / 257 |
Version history: | 7 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |