[dmd-concurrency] draft 7
Sean Kelly
sean at invisibleduck.org
Mon Feb 1 11:31:13 PST 2010
I just have time for a quick reading, but here are a few comments:
1.5 uses tid.send() while 1.6 uses send(tid) with no explanation as to why. Perhaps send(tid) should be used throughout, with tid.send() optionally introduced later after shared UDTs are discussed.
Time values in Druntime use a resolution of 100 nanoseconds (same as C#). We should probably expose the same for messaging. In truth, we really need a TimeSpan struct to simplify things, since expressing time intervals using numeric literals is horribly error-prone.
I must say I still kind of like having a timeout handler within receive:
receive( (int x) {},
(string y) {},
timeout(1000, { writeln("timed out"); } );
but I guess both could really be offered with receiveTimeout as a wrapper around receive, similar to receiveOnly.
The code snippet for 1.6.1 spans 2 pages. Necessary, I suppose, but I've never liked when that happens.
1.10 - If I change the size of a mailbox to be less than the number of messages currently in the mailbox, what happens?
1.11 Why atomicOp!"+="(x, 1) instead of atomic(x) += 1?
1.12 "The notable absent is real" -> "The notable absence is real" or perhaps "real is notably absent"
1.12.1 There should be some mention about whether unshared operations can be optimized across shared operations. This is basically the Java memory model for volatile, so it may be worth looking at how that's explained or simply mentioning this as well.
1.13 "scope(exit) _guard.unlock();" would work as well.
1.14.1 I assume you mean that if the address of a field escapes, all accesses of that field must be atomic? You can't mix atomic and non-atomic accesses to a variable. I like that you've tried to use the type system to simplify things here, but this seems like a potential problem.
1.14.2 What is _parent?
1.15 Multi-argument synchronized() is cool.
More information about the dmd-concurrency
mailing list