Another question I found while reading the manual:

The manual says that immutable boxes are shared and are destroyed when the reference count gets to zero.

The problem, if I understand it correctly, is that the destructors are user visible, but the creation of immutable shared boxes is not in all cases.

When sending something over a channel the runtime can increment the reference copy or do an actual copy (if going to another os thread for example). If it copies now the destructors are run twice.

We discussed some options

*) Require that resources be reference counted. Really expensive, since the reference count would have to be atomic.

*) Distinguish copyable and non-copyable mutable data. A destructor can then only get non copyable data and only copyable data can be sent over a channel (short of a move).

Is the second option in line with what you had in mind?

Thanks,
Rafael
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to