Closed embediver closed 8 months ago
After thinking about this approach for a while, I'm not so sure anymore that its the correct way to solve the Bug.
While the Bug we had is solved, now the Problem is just shifted to the user, which can easily crash his application. Now when a Receiver (e.g. the MqttConnection) is dropped, the same infinite block we had, can happen to the Channel when it is waiting to share a value at that moment. While its not likely that this happens for the most usecases, it would be a pain to debug if it were to happen.
The Channel is still public though, in my opinion its better to make it private and use the channel only with QuitOnDrop by providing a function which creates a new channel and returns a QuitOnDrop and a Receiver.
@ivmarkov Do you have other opinions or should this PR be closed?
Previously Receiver held a Weak<Channel>,
now Channel holds a Weak<Receiver>.
The Receiver now holds the Condvar and State.
Also Receiver becomes a Arc<Receiver>.
By this the Channel can be dropped while the Receiver is waiting.