Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
May 23, 2013 std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
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 Re: std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Luís Marques | 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 Re: std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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 Re: std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Luís Marques | 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 Re: std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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 24, 2013 Re: std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Luís Marques | On May 23, 2013, at 11:49 AM, "Luís.Marques" <luismarques@gmail.com>"@puremagic.com <luismarques@gmail.com> wrote: > 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. 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 Re: std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | 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 25, 2013 Re: std.concurrency doesn't like structs, classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Luís Marques | On May 24, 2013, at 3:50 PM, "Luís.Marques" <luismarques@gmail.com>"@puremagic.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 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? The bug is with Variant, which std.concurrency uses. I'd love to see Variant improved though. |
Copyright © 1999-2021 by the D Language Foundation