Skip to content

v1.1.0

Choose a tag to compare

@djherbis djherbis released this 22 Apr 18:39

API Updates

  • Capped buffer API available for fixing the size of the in-memory buffer [prevent unbounded growth]. This does come with the caveat that a slow reader can slow other readers and block the writer.
  • NextReaderFromNow() creates a new reader which only sees new writes (NextReader() sees data from the start of the buffer, which usually equates to the position of the most behind reader).
  • Exposed Buffer.Len() to get the current size of the in-memory buf
  • Exposed NumReaders() so you can check current number of subscribed readers
  • Added OnLastReaderClose so you can take an action whenever NumReaders() falls to zero after a Reader close (so it won't trigger when the writer starts off at 0 readers).

Important Note: regarding OnLastReaderClose: you should be careful about races in your code logic (a new reader could join before/while this callback is run, so you may want to lock between NextReader[FromNow]() calls and this call (and check NumReaders()) if you want to guarantee the number of readers during this call is correct and consistent. I make synchronize these calls in a future release, but for now I want to avoid adding more locks.

Bug Fixes

  • Write after close is now an error, special thanks @tmm1
  • Multiple calls to reader.close() is idempotent now (previously caused buffer state issues)