September 25, 2012 Re: Passing associative array to another thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | On 2012-09-25 00:47, Sean Kelly wrote: > If you're passing via std.concurrency then you'll currently have to cast to shared. I'd been considering allowing Unique!T to be sent as well, but haven't done so yet. Hey, if it's immutable why use std.concurrency at all? Just import the module and use the variable willy nilly. I mean, isn't that the whole point of immutable anyway, you can share it freely among threads without any risks? -- /Jacob Carlborg |
September 25, 2012 Re: Passing associative array to another thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Drasar | On 2012-09-21 16:33, Martin Drasar wrote: > Hi, > > I am using the std.concurrency module and I would like to send an > associative array to another thread. > > If I try this: > > string[string] aa; > someThread.send(aa); > > I get: Aliases to mutable thread-local data not allowed. > > And if I try to use this: > > immutable(string[string]) aa; > someThread.send(aa); > > I get: > /usr/include/d/dmd/phobos/std/variant.d(539): Error: *p is not mutable BTW, why do you need to use std.currency at all if it's immutable, just share it as a global. The whole point of immutable is that it can be freely shared among threads without any risks. -- /Jacob Carlborg |
September 25, 2012 Re: Passing associative array to another thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Dne 25.9.2012 18:19, Jacob Carlborg napsal(a):
> BTW, why do you need to use std.currency at all if it's immutable, just
> share it as a global. The whole point of immutable is that it can be
> freely shared among threads without any risks.
It is not some single piece of data.
I have a queue of tasks. Each task is a struct that contains among other things a user-supplied delegate and an AA with parameters for that delegate.
These tasks are created somewhere, inserted into the queue and then executed in parallel. Once created they are not modified anywhere and should exist only in one instance that is passed to that delegate.
It's just that I haven't found a better way to pass parameters that are unknown before to a delegate.
Martin
|
Copyright © 1999-2021 by the D Language Foundation