Bug 9005 – std.concurrency.spawn should allow `void delegate(Args) shared` for new Tid

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-12T05:14:00Z
Last change time
2013-02-05T12:54:37Z
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2012-11-12T05:14:19Z
This code should be allowed: -------------- import core.atomic, core.thread; import std.concurrency; import core.sync.barrier; class Foo { shared int a = 0; void bar(shared Barrier barrier) shared { while (1) { Thread.sleep(dur!"msecs"(10)); if (a.atomicLoad() > 100) break; } (cast()barrier).wait(); } void countup() shared { foreach (i; 0..200) { Thread.sleep(dur!"msecs"(10)); a.atomicStore(i); } } } void main() { auto barrier = new Barrier(2); auto foo = new Foo; spawn(&foo.bar, cast(shared)barrier); foo.countup(); barrier.wait(); } -------------- The Foo.bar is thread-safe. So, making new Tid by spawn with the shared member function is no problem.
Comment #1 by github-bugzilla — 2012-11-19T08:33:45Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f909a18dca275308c5b24671121e1ee2d2d66170 fix Issue 9005 - std.concurrency.spawn should allow `void delegate(Args) shared` for new Tid http://d.puremagic.com/issues/show_bug.cgi?id=9005 https://github.com/D-Programming-Language/phobos/commit/5274ebc0326fe9c6ea5b64622f07e31a7732ca69 Merge pull request #947 from shoo/fix9005 fix Issue 9005 - std.concurrency.spawn should allow `void delegate(Args) shared` for new Tid
Comment #2 by yebblies — 2013-01-12T19:59:08Z
Is this fixed now?
Comment #3 by andrej.mitrovich — 2013-02-05T12:54:37Z
Fixed, however the sample needs to change: auto foo = new Foo; to: auto foo = new shared(Foo);