Open darkestpigeon opened 1 week ago
Found some apparent problems with the compiler due to this change, distilled and reported them in nim-lang/Nim#24374
Here the =destroy
, and hence tryRecv
can be called with a wrong type during flushing, which can lead to a segfault or other nasty behaviour.
Right now when a channel with pending messages is destroyed, a memory leak can occur if the messages themselves have non-trivial destructors. This PR aims to fix this via receiving all the pending messages during channel destruction. Also adding
tryRecv
withOption[T}
result instead of an out parameter and a boolean flag for convenience.