diff --git a/lib/mailbox.dart b/lib/mailbox.dart index be89016..98e32fe 100644 --- a/lib/mailbox.dart +++ b/lib/mailbox.dart @@ -68,7 +68,8 @@ class Mailbox { /// Place a message into the mailbox if has space for it. /// - /// If mailbox already contains a message then [put] will throw. + /// If mailbox already contains a message or mailbox is closed then [put] will + /// throw [StateError]. void put(Uint8List message) { final buffer = message.isEmpty ? nullptr : _toBuffer(message); _mutex.runLocked(() { @@ -86,7 +87,7 @@ class Mailbox { /// Close a mailbox. /// - /// If mailbox already contains a message then it will be dropped. + /// If mailbox already contains a message then [close] will drop the message. void close() => _mutex.runLocked(() { if (_mailbox.ref.state == _stateFull && _mailbox.ref.bufferLength > 0) { malloc.free(_mailbox.ref.buffer); @@ -101,8 +102,8 @@ class Mailbox { /// Take a message from the mailbox. /// - /// If mailbox is empty this will synchronously block until message - /// is available. + /// If mailbox is empty then [take] will synchronously block until message + /// is available. If mailbox is closed then [take] will throw [StateError]. Uint8List take() => _mutex.runLocked(() { while (_mailbox.ref.state == _stateEmpty) { _condVar.wait(_mutex);