Re: Multi-Thread message passing approach

2016-08-16 Thread Charles Hixson via Digitalmars-d-learn
On 08/16/2016 07:21 AM, Kagamin via Digitalmars-d-learn wrote: On Monday, 15 August 2016 at 01:53:33 UTC, Charles Hixson wrote: If I modify the code to attempt to pass a Tid[] as a member of struct Start I get: /usr/include/dmd/phobos/std/concurrency.d(603): Error: static assert "Aliases

Re: Multi-Thread message passing approach

2016-08-16 Thread Kagamin via Digitalmars-d-learn
On Monday, 15 August 2016 at 01:53:33 UTC, Charles Hixson wrote: If I modify the code to attempt to pass a Tid[] as a member of struct Start I get: /usr/include/dmd/phobos/std/concurrency.d(603): Error: static assert "Aliases to mutable thread-local data not allowed." test.d(47):

Re: Multi-Thread message passing approach

2016-08-15 Thread Charles Hixson via Digitalmars-d-learn
I misunderstood the problem. The problem was that a dynamically sized array cannot be sent as a message. So this works: import std.concurrency; import std.stdio; import core.thread; enum tidMax = 10; struct Start { int tidCnt = 0; Tid[tidMax] tids; } struct Msg { int

Re: Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
Looking at the std.concurrency code, it appears that Tid is just a handle to a class, so multiple assignments should all refer to the same underlying class, and it looks like that underlying class (MessageBox) uses mutexes to ensure safe handling of multiple access. So this shared access to

Re: Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
On 08/14/2016 07:44 AM, Charles Hixson via Digitalmars-d-learn wrote: This is an approach to n x n thread message passing. The idea is that each thread should be able to pass messages to any other thread. The only alternative I've come up with involves the main thread handling each message.

Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
This is an approach to n x n thread message passing. The idea is that each thread should be able to pass messages to any other thread. The only alternative I've come up with involves the main thread handling each message. Is that a better approach? Is there a better way to pass lists of