www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.concurrency doesn't like structs, classes?

reply =?UTF-8?B?Ikx1w61z?= Marques" <luismarques gmail.com> writes:
Hi,

Has anyone tried the example from std.concurrency, but changing 
the int to an (immutable) struct or class? When I did that it 
failed with "Owner terminated". When I added a Variant to the 
receive() list, to try and fix that, I got an assertion failure 
(but the receive() handler was called).

Luís
May 23 2013
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 05/23/2013 10:57 AM, "Luís Marques" <luismarques gmail.com>" wrote:

 Has anyone tried the example from std.concurrency, but changing the int
 to an (immutable) struct or class? When I did that it failed with "Owner
 terminated". When I added a Variant to the receive() list, to try and
 fix that, I got an assertion failure (but the receive() handler was
 called).

 Luís
Why not provide a short program instead of describing? :) Could be this bug: http://d.puremagic.com/issues/show_bug.cgi?id=5538 Ali
May 23 2013
parent reply =?UTF-8?B?Ikx1w61z?= Marques" <luismarques gmail.com> writes:
On Thursday, 23 May 2013 at 18:09:34 UTC, Ali Çehreli wrote:
 Could be this bug:

   http://d.puremagic.com/issues/show_bug.cgi?id=5538
Thanks. I guess it's that bug. But the bug is two years old, I'm not very hopeful to see a fix soon :(
May 23 2013
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 05/23/2013 11:16 AM, "Luís Marques" <luismarques gmail.com>" wrote:
 On Thursday, 23 May 2013 at 18:09:34 UTC, Ali Çehreli wrote:
 Could be this bug:

   http://d.puremagic.com/issues/show_bug.cgi?id=5538
Thanks. I guess it's that bug. But the bug is two years old, I'm not very hopeful to see a fix soon :(
As a workaround, try immutable(S*) (S is a struct). You must manage the lifetime of the object of course. Ali
May 23 2013
parent reply =?UTF-8?B?Ikx1w61z?= Marques" <luismarques gmail.com> writes:
On Thursday, 23 May 2013 at 18:38:05 UTC, Ali Çehreli wrote:
 As a workaround, try immutable(S*) (S is a struct). You must 
 manage the lifetime of the object of course.
I was actually investigating std.concurrency to try to understand the mechanism of dispatching the messages of different types (I needed to figure out a mechanism to accept subclasses). Since some things were not clear to me, I thought the easier solution was just to progressively strip std.concurrency, until I isolated the functionality I wanted. But now that seems a dead end, since std.concurrency itself does not work for classes.
May 23 2013
parent reply Sean Kelly <sean invisibleduck.org> writes:
On May 23, 2013, at 11:49 AM, "Lu=EDs.Marques" =
<luismarques gmail.com>" puremagic.com <luismarques gmail.com> wrote:

 On Thursday, 23 May 2013 at 18:38:05 UTC, Ali =C7ehreli wrote:
 As a workaround, try immutable(S*) (S is a struct). You must manage =
the lifetime of the object of course.
=20
 I was actually investigating std.concurrency to try to understand the =
mechanism of dispatching the messages of different types (I needed to = figure out a mechanism to accept subclasses).
=20
 Since some things were not clear to me, I thought the easier solution =
was just to progressively strip std.concurrency, until I isolated the = functionality I wanted. But now that seems a dead end, since = std.concurrency itself does not work for classes. It should work for any type that Variant can represent. I know Variant = has trouble with immutable however. Have you tried shared? = std.concurrency finds a match via Variant.convertsTo, so it should be = able to handle subclassing.=
May 24 2013
parent reply =?UTF-8?B?Ikx1w61z?= Marques" <luismarques gmail.com> writes:
On Friday, 24 May 2013 at 21:49:48 UTC, Sean Kelly wrote:
 It should work for any type that Variant can represent.  I know 
 Variant has trouble with immutable however.  Have you tried 
 shared?  std.concurrency finds a match via Variant.convertsTo, 
 so it should be able to handle subclassing.
I managed to solve the original problem, without using std.concurrency as inspiration, like I mentioned I was doing. I have one more question regarding the original problem, but I posted that to .learn (by mistake, the first part of the post was a D / DMD issue, oops). Still, on this topic of std.concurrency, would it be too hard to solve the bug, for the benefit of others?
May 24 2013
parent Sean Kelly <sean invisibleduck.org> writes:
On May 24, 2013, at 3:50 PM, "Lu=C3=ADs.Marques" <luismarques gmail.com>" pu=
remagic.com wrote:

 On Friday, 24 May 2013 at 21:49:48 UTC, Sean Kelly wrote:
 It should work for any type that Variant can represent.  I know Variant h=
as trouble with immutable however. Have you tried shared? std.concurrency f= inds a match via Variant.convertsTo, so it should be able to handle subclass= ing.
=20
 I managed to solve the original problem, without using std.concurrency as i=
nspiration, like I mentioned I was doing.
=20
 I have one more question regarding the original problem, but I posted that=
to .learn (by mistake, the first part of the post was a D / DMD issue, oops= ).
=20
 Still, on this topic of std.concurrency, would it be too hard to solve the=
bug, for the benefit of others? The bug is with Variant, which std.concurrency uses. I'd love to see Varian= t improved though.=20=
May 25 2013