Class LSpace<K,V>
java.lang.Object
org.jpos.space.LSpace<K,V>
- All Implemented Interfaces:
AutoCloseable, Runnable, LocalSpace<K,V>, Space<K, V>, Loggeable
LSpace (Loom-optimized Space) implementation with per-key locking for Virtual Thread efficiency.
This implementation addresses the thundering herd problem in traditional Space implementations
by using per-key ReentrantLock and Condition objects instead of global synchronization.
With Virtual Threads (Project Loom), this prevents thousands of threads from being
unnecessarily woken up when only one is relevant.
Key features:
- Per-key isolation: Each key has its own lock and condition variables
- Targeted wakeups: Only threads waiting on a specific key are signaled
- Virtual Thread optimized: Scales efficiently with thousands of concurrent threads
- Full LocalSpace compatibility: Drop-in replacement with same API and behavior
- JFR instrumentation: All operations emit SpaceEvent for monitoring
- Since:
- 3.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Object key, SpaceListener listener) add a SpaceListener associated with a given keyvoidaddListener(Object key, SpaceListener listener, long timeout) add a SpaceListener associated with a given key for a given period of time.voidclose()Cancels the periodic GC task so this instance can be garbage-collected.voiddump(PrintStream p, String indent) booleanbooleanvoidgc()Non-standard method (required for space replication) - use with care.Take an entry from the space, waiting forever until one exists.Take an entry from the space, waiting a limited amount of time until one exists.In probe takes an entry from the space if one exists, return null otherwise.booleanisEmpty()voidnotifyListeners(Object key, Object value) voidNrd (not read) waits forever until Key is not present in space.
Resolution for expiring entries is implementation dependant, but a minimum one-second is suggested.Nrd (not read) waits up to timeout until Key is not present in space.
Resolution for expiring entries is implementation dependant, but a minimum one-second is suggested.voidWrite a new entry into the SpacevoidWrite a new entry into the Space, with an timeout valuevoidWrite a new entry at the head of a queue.voidWrite a new entry at the head of the queue with a timeout valuevoidWrite a single entry at the head of the queue discarding the other entriesvoidWrite a single entry at the head of the queue discarding the other entries, with timeout.Read an entry from the space, waiting forever until one exists.Read an entry from the space, waiting a limited amount of time until one exists.Read probe reads an entry from the space if one exists, return null otherwise.voidremoveListener(Object key, SpaceListener listener) removes a SpaceListener associated with a given keyvoidrun()voidsetEntries(Map entries) Non-standard method (required for space replication) - use with care.int
-
Field Details
-
GCDELAY
- See Also:
-
-
Constructor Details
-
LSpace
public LSpace()
-
-
Method Details
-
out
-
out
-
push
-
push
-
put
-
put
Description copied from interface:SpaceWrite a single entry at the head of the queue discarding the other entries, with timeout. -
rdp
-
inp
-
in
-
in
-
rd
-
rd
-
nrd
Description copied from interface:SpaceNrd (not read) waits forever until Key is not present in space.
Resolution for expiring entries is implementation dependant, but a minimum one-second is suggested. -
nrd
Description copied from interface:SpaceNrd (not read) waits up to timeout until Key is not present in space.
Resolution for expiring entries is implementation dependant, but a minimum one-second is suggested. -
existAny
-
existAny
-
run
-
gc
-
size
-
addListener
Description copied from interface:LocalSpaceadd a SpaceListener associated with a given key- Specified by:
addListenerin interfaceLocalSpace<K,V> - Parameters:
key- Entry's keylistener- a SpaceListener
-
addListener
Description copied from interface:LocalSpaceadd a SpaceListener associated with a given key for a given period of time. Warning: not supported by all space implementations.- Specified by:
addListenerin interfaceLocalSpace<K,V> - Parameters:
key- Entry's keylistener- a SpaceListenertimeout- listener registration timeout in millis
-
removeListener
Description copied from interface:LocalSpaceremoves a SpaceListener associated with a given key- Specified by:
removeListenerin interfaceLocalSpace<K,V> - Parameters:
key- Entry's keylistener- the SpaceListener
-
isEmpty
-
getKeySet
-
getKeysAsString
-
dump
-
notifyListeners
-
getEntries
Non-standard method (required for space replication) - use with care. -
setEntries
Non-standard method (required for space replication) - use with care. -
close
-