Skip to content

Commit

Permalink
feat: Adjust and implement new tests for the lock-free ringbuffer imp…
Browse files Browse the repository at this point in the history
…lementation.

* Adjusted current tests for the lock-free behavior.
* Added tests for the non-blocking implementation.
* Implemented new tests for scenarios, where one thread always runs slower than the other.
  • Loading branch information
Imaniac230 committed Mar 6, 2024
1 parent 1c03d79 commit ed06e57
Show file tree
Hide file tree
Showing 2 changed files with 491 additions and 22 deletions.
12 changes: 10 additions & 2 deletions ouster-ros/src/thread_safe_ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,19 @@ class ThreadSafeRingBuffer {
protected:
/**
* Resets the write_idx to an initial value.
* @remarks Should be mostly used by tests to allow reading of the final
* item left in the buffer.
* @remarks
* Should be mostly used by tests to allow reading of the final item left
* in the buffer or restarting the test scenario.
*/
void reset_write_idx() { write_idx = SIZE_MAX; }

/**
* Resets the read_idx to an initial value.
* @remarks
* Should be mostly used by tests to allow restarting the test scenario.
*/
void reset_read_idx() { read_idx = SIZE_MAX; }

private:
/**
* Performs the actual sequence of operations for writing.
Expand Down
Loading

0 comments on commit ed06e57

Please sign in to comment.