put method
Place a message into the mailbox if has space for it.
If mailbox already contains a message or mailbox is closed then put will throw StateError.
Implementation
void put(Uint8List message) {
final buffer = message.isEmpty ? nullptr : _toBuffer(message);
_mutex.runLocked(() {
if (_mailbox.ref.state != _stateEmpty) {
throw StateError('Mailbox is closed or full');
}
_mailbox.ref.state = _stateFull;
_mailbox.ref.buffer = buffer;
_mailbox.ref.bufferLength = message.length;
_condVar.notify();
});
}