My first thought was to store an oneshot channel sender in the struct and fire it within the Drop
impl. This works fine, but then I realized that it doesn't need to be fired, as it will throw an error on the receiver side anyway if dropped. So I chose Channel<Infallible>
, but this feels a bit hacky. Are you aware of any other solutions?
You could store Arc<AtomicBool>
inside the structure to transmit a single bit of information like that.
1 Like
Using a channel like that seems fine. If you need the other side to be able to wait for the event, it is going to require a bit of locking and thread management, which I expect to look 99% like a oneshot channel implementation anyway.
1 Like
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.