[rust-dev] Reading shared immutable data

Patrick Walton pwalton at mozilla.com
Mon Dec 17 18:29:57 PST 2012

On 12/17/12 6:27 PM, Michael Neumann wrote:
> Am 18.12.2012 03:11, schrieb Patrick Walton:
>> * Use unsafe code by casting to an unsafe pointer and sending the
>> unsafe pointer over a channel; do this only as a last resort.
> But don't I get into problems with GC when I do that? So I create the
> data structure heap allocated in one thread, then get an unsafe pointer
> to it and sent
> this to all other threads. Of course in the originating thread I need to
> keep the reference to the data, otherwise the unsafe pointer will point
> to garbage.

Right. You'd need to keep a reference to it alive.


More information about the Rust-dev mailing list