Skip to content

Conversation

@barspi
Copy link
Contributor

@barspi barspi commented Jan 5, 2026

(read NOTE below to avoid headaches)

In the same spirit as the commit that unified the logic of many consumers under awaitValue(), this pull request does it with the producer ("enqueuer") methods.

After careful comparison, all 6 producer methods versions{out, push, put} X { timeout, no-timeout} were basically the same. The main difference being where they would add the new value (at head or tail of the queue) and whether they would clear the queue (put) or not (out and push) and a some status flag such as hasExpirable.

Now all the core logic has been unified in a single method:
private void enqueueValue(String opTag, K key, V value, long timeout, Enqueuer op)

This method accepts a lambda implementing an Enqueuer functional interface, where the specific differences of out, put, push are tackled. Then enqueueValue() calls the Enqueuer at some specific point inside all the other common boilerplate.

All tests related to LSpace pass successfully (and all others as well)


NOTE: In order to make the diffs more digestible by human eyes, this PR is split in two commits.

  1. ba2ba8f4 LSpace: non-timeout producer methods in terms of the timeout versions.
    This one mainly implements the non-timeout versions by calling the timeout versions using the constant long NO_TIMEOUT = -1L which works well as they were equivalent and the timeout argument is treated correctly for all cases.
    There's no need to spend much time with this commit; just take it as "reduce the noise for the following one"

  2. 37ad9d1 LSpace: unfiy logic of producer methods
    This is the one to look at!
    It introduces the functional Enqueuer and extracts the boilerplate into enqueueValue()

@barspi barspi force-pushed the lspace-unify-producers branch from ed84ee6 to be10be5 Compare January 6, 2026 19:26
@barspi barspi force-pushed the lspace-unify-producers branch from 9ced465 to 37ad9d1 Compare January 7, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant