Skip to content

Commit

Permalink
feat-squash: Adjust and implement new tests for the lock-free ringbuf…
Browse files Browse the repository at this point in the history
…fer implementation.

* 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 Feb 26, 2024
1 parent 6aba481 commit d008126
Show file tree
Hide file tree
Showing 2 changed files with 265 additions and 142 deletions.
9 changes: 8 additions & 1 deletion ouster-ros/src/thread_safe_ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ class ThreadSafeRingBuffer {
/**
* 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.
* 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 d008126

Please sign in to comment.