how to handle shared arrays?
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jun 22 02:15:01 PDT 2012
On Friday, June 22, 2012 11:09:13 maarten van damme wrote:
> It looks a bit "dirty" to
> convert to immutable and back to mutable simply to pass it over to
> another thread...
It is, but casting to shared and back again is pretty much the same thing. So,
in most cases, you're going to end up doing one or the other if you're trying
to pass ownership across threads rather than sending an immutable duplicate
across. It would be great if there were a way in the type system to model
transfering ownership from one thread to another, but there isn't (if nothing
else, because it's not easy to do), so you get to choose between transferring
ownship using "dirty" casts and duplicating data to send it across. Certainly,
if efficiency isn't an issue, iduping is safer, since it's @safe rather than
@system.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list