Libraryless. Click here for Pure Java version (2894L/17K).
1 | static <A> O vmBus_onMessage_withLivelinessCheck(bool verbose default false, IF0<Bool> livelinessCheck, S msg, IVF1<A> onMessage) { |
2 | // Do this BEFORE synchronizing on the map! |
3 | VMBusListenerWithLivelinessCheck listener = new(null, livelinessCheck, (_msg, arg) -> onMessage.get((A) arg)); |
4 | listener.verbose = verbose; |
5 | |
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 | listener.listeners = listeners; |
11 | // We're technically violating the one-synchronized-object-per-thread rule, |
12 | // but it should be OK here. |
13 | listeners.add(listener); |
14 | ret listener; |
15 | } |
16 | } |
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: | 173 / 258 |
Version history: | 7 change(s) |
Referenced in: | [show references] |