RepoPilot

How do their APIs compare?

About lmax-exchange/disruptor · 2 messages · last activity 8/16/2026

Question

How do their APIs compare?

RepoPilot

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 like next() and tryNext().
  • Sequencer implementations — SingleProducerSequencer [src/main/java/com/lmax/disruptor/SingleProducerSequencer.java:L1-L24] and MultiProducerSequencer [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 via VarHandle/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 of Sequence objects [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 with EventHandler + BatchEventProcessor instead 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 by RingBuffer#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 default ExceptionHandler [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 and JSONObject, e.g. toString(JSONObject jo) builds a request/response header from JSON fields, throwing JSONException if 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 a Builder, toString(), and toURIFragment() for URI-escaped pointer output [src/test/java/org/json/junit/JSONPointerTest.java:L180-L219 shows usage/expected behavior].
  • XMLTokener — internal helpers like parseHexEntity and parseDecimalEntity for decoding XML character references into code points, throwing JSONException on malformed input [src/main/java/org/json/XMLTokener.java:L175-L214].
  • Test utilities like Util.compareActualVsExpectedJsonArrays/compareActualVsExpectedJsonObjects show 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/disruptor

Public 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.