Skip to content

Commit 1967a1d

Browse files
committed
Improving wording in a comment
Comment for `get_write_reservation()` was misleading, e.g. about calling the method being "pure".
1 parent fd63cf0 commit 1967a1d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

include/LockFreeSpscQueue.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,16 +698,18 @@ class LockFreeSpscQueue
698698
friend struct ReadScope;
699699

700700
/**
701-
* @brief Performs the core logic to reserve a contiguous block of space for writing.
701+
* @brief Performs the core logic to calculate a reservation for a write operation.
702702
* @details This is a private helper that centralizes the write reservation logic,
703703
* which is shared by `prepare_write` and `try_start_write`. It implements
704704
* the "fast path/slow path" optimization by first checking against the
705705
* producer's cached `read_pos` and only performing an expensive `acquire`
706706
* load on the consumer's true `read_pos` when necessary.
707-
* @note This function is pure and does not modify the queue's state. It only
708-
* calculates and returns the potential reservation parameters. The actual
709-
* commit is handled by the RAII objects created by the public API methods.
710-
* @param num_items The desired number of items to reserve space for.
707+
* @note This function is responsible only for the calculation of a reservation;
708+
* it does not perform the final "commit" that makes the space available. While
709+
* it may update the producer's internal `cached_read_pos` as a performance
710+
* optimization, it never modifies the queue's main `write_pos` index.
711+
* The actual commit (advancing `write_pos`) is the exclusive responsibility
712+
* of the RAII scope objects (`WriteScope`, `WriteTransaction`).
711713
* @return A tuple containing {start_index1, block_size1, start_index2, block_size2}.
712714
* If no space is available, all values in the tuple will be zero.
713715
*/

0 commit comments

Comments
 (0)