Re: using shared effectively in a producer/consumer situation.

2017-04-25 Thread Kagamin via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:33:48 UTC, Kevin Balbas wrote: Is this the correct way to do it? cast to shared, send to main thread, cast away shared? Yes, as long as the thing is unique, you can cast it to shared or immutable just fine.

Re: using shared effectively in a producer/consumer situation.

2017-04-23 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:33:48 UTC, Kevin Balbas wrote: I guess the follow up here is: Is this the correct way to do it? cast to shared, send to main thread, cast away shared? At the moment, pretty much yes. Either that or make the (unnecessary) immutable copies. There are no

Re: using shared effectively in a producer/consumer situation.

2017-04-23 Thread Kevin Balbas via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:30:33 UTC, Kevin Balbas wrote: I have an application where a long-lived "loader" thread takes messages to load data, loads that data, and then sends it back to the main thread via the standard concurrency primitives. Something like this: void threadFunc(Tid

using shared effectively in a producer/consumer situation.

2017-04-23 Thread Kevin Balbas via Digitalmars-d-learn
I have an application where a long-lived "loader" thread takes messages to load data, loads that data, and then sends it back to the main thread via the standard concurrency primitives. Something like this: void threadFunc(Tid ownerTid) { while(true) { receive(