Libraryless. Click here for Pure Java version (2821L/17K).
// The lazy man's method of registering a VM bus listener // You only need to keep a reference around but not to close() anything // OTOH you depend on the GC for cleaning up your listener // structures which is not so good sclass WeakRefVMBusListener extends WeakReference implements IF2<S, O, O> { Set listeners; // where we were added *(Set *listeners, O listener) { super(listener); } *(Set *listeners, IVF2<S, O> listener) { super(listener); } public O get(S msg, O arg) { O listener = get(); if (listener == null) { ifdef WeakRefVMBusListener_debug print WeakRefVMBusListener_debug("Removing VM bus listener"); endifdef remove(listeners, this); null; } ret callF(listener, msg, arg); } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031569 |
Snippet name: | WeakRefVMBusListener |
Eternal ID of this version: | #1031569/9 |
Text MD5: | 59f6e889cc319db0dd2c04c424758ba6 |
Transpilation MD5: | b86b671393602b377763c308354b43db |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-22 04:04:35 |
Source code size: | 778 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 220 / 396 |
Version history: | 8 change(s) |
Referenced in: | #1031572 - VMBusListenerWithLivelinessCheck #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |