How do their APIs compare?
How do their APIs compare?
About lmax-exchange/disruptor · 2 messages · last activity 8/16/2026
Comparing the APIs of lmax-exchange/disruptor and stleary/json-java
These two libraries serve fundamentally different purposes, so their APIs are shaped very differently.
lmax-exchange/disruptor: concurrency/messaging API
Disruptor's API is built around a small set of interacting abstractions for high-performance inter-thread communication:
RingBuffer— the core data structure producers/consumers operate on, with claim methods likenext()andtryNext().Sequencerimplementations —SingleProducerSequencer[src/main/java/com/lmax/disruptor/SingleProducerSequencer.java:L1-L24] andMultiProducerSequencer[src/main/java/com/lmax/disruptor/MultiProducerSequencer.java:L1-L33] — these are the coordinators for claiming sequences, one optimized for a single publisher thread, the other safe for multiple publisher threads viaVarHandle/atomic operations.AbstractSequencer— shared base class handling gating-sequence management and cursor ownership [src/main/java/com/lmax/disruptor/AbstractSequencer.java:L1-L27].SequenceGroups— static helper methods for managing groups ofSequenceobjects [src/main/java/com/lmax/disruptor/SequenceGroups.java:L1-L24].EventProcessor— the runnable abstraction that polls the ring buffer using a wait strategy; most users interact withEventHandler+BatchEventProcessorinstead of implementing this directly [src/main/java/com/lmax/disruptor/EventProcessor.java:L1-L25].- Wait strategies, e.g.
YieldingWaitStrategy, which trades CPU usage for lower latency by yielding rather than blocking [src/main/java/com/lmax/disruptor/YieldingWaitStrategy.java:L1-L25]. InsufficientCapacityException— a stack-trace-free exception thrown byRingBuffer#tryNext()when the buffer can't accept a claim without wrapping consumers [src/main/java/com/lmax/disruptor/InsufficientCapacityException.java:L1-L25].ExceptionHandlers— static accessors for a defaultExceptionHandler[src/main/java/com/lmax/disruptor/ExceptionHandlers.java:L1-L18].
This is an API oriented around object lifecycle, concurrency guarantees, and performance tuning (which sequencer/wait strategy to pick) rather than data transformation.
stleary/json-java: data-model/parsing API
json-java's API centers on representing and converting JSON/XML/HTTP data structures:
HTTP— converts between HTTP header strings andJSONObject, e.g.toString(JSONObject jo)builds a request/response header from JSON fields, throwingJSONExceptionif required fields are missing [src/main/java/org/json/HTTP.java:L94-L133], and the reverse direction (header string → JSONObject) is documented starting at [src/main/java/org/json/HTTP.java:L14-L53].JSONPointer— supports building/parsing JSON Pointers with aBuilder,toString(), andtoURIFragment()for URI-escaped pointer output [src/test/java/org/json/junit/JSONPointerTest.java:L180-L219 shows usage/expected behavior].XMLTokener— internal helpers likeparseHexEntityandparseDecimalEntityfor decoding XML character references into code points, throwingJSONExceptionon malformed input [src/main/java/org/json/XMLTokener.java:L175-L214].- Test utilities like
Util.compareActualVsExpectedJsonArrays/compareActualVsExpectedJsonObjectsshow the API's data-comparison semantics (order-independent equality checks) [src/test/java/org/json/junit/Util.java:L18-L57].
This API is oriented around parsing, converting, and querying tree-structured data (JSON objects/arrays, XML, HTTP headers, pointers), with exceptions (JSONException) used for malformed input rather than concurrency signaling.
Key contrast
- Domain: Disruptor's API is about coordinating threads and memory access (s
Want to ask your own question?
Open chat for lmax-exchange/disruptorPublic Q&A. Generated by RepoPilot from the actual source of lmax-exchange/disruptor. AI answers can be incomplete or stale — verify before relying on them.