Re: shared: Has anyone used it without a lot of pain?

2017-04-06 Thread Guillaume Piolat via Digitalmars-d
On Thursday, 6 April 2017 at 13:52:01 UTC, deadalnix wrote: Right now, there are no way to transfers ownership from one thread to another, so you pretty much got to cast to shared, move data to the other thread and then cast back to not shared. (People who followed closely will notice that

Re: shared: Has anyone used it without a lot of pain?

2017-04-06 Thread deadalnix via Digitalmars-d
On Wednesday, 5 April 2017 at 14:01:24 UTC, Guillaume Piolat wrote: Do we have a missed opportunity with shared? Yes we do. The #1 problem is that it lack a bridge to and from the "normal" thread local world. there is literally no way to use shared in a correct way, you always need to

Re: shared: Has anyone used it without a lot of pain?

2017-04-06 Thread Shachar Shemesh via Digitalmars-d
On 06/04/17 12:37, Suliman wrote: On Thursday, 6 April 2017 at 09:00:33 UTC, Kagamin wrote: On Wednesday, 5 April 2017 at 14:01:24 UTC, Guillaume Piolat wrote: My pet peeve with shared is the RoI. Risk of infection? Return of Investment :) Actually, to be pedantic, it's "return *on*

Re: shared: Has anyone used it without a lot of pain?

2017-04-06 Thread Suliman via Digitalmars-d
On Thursday, 6 April 2017 at 09:00:33 UTC, Kagamin wrote: On Wednesday, 5 April 2017 at 14:01:24 UTC, Guillaume Piolat wrote: My pet peeve with shared is the RoI. Risk of infection? Return of Investment :)

Re: shared: Has anyone used it without a lot of pain?

2017-04-06 Thread Kagamin via Digitalmars-d
On Wednesday, 5 April 2017 at 14:01:24 UTC, Guillaume Piolat wrote: My pet peeve with shared is the RoI. Risk of infection? You were supposed to use it whenever something is "shared across threads". My problem with it is with the RoI of putting entire object graphs under that type

Re: shared: Has anyone used it without a lot of pain?

2017-04-05 Thread via Digitalmars-d
On Tuesday, 4 April 2017 at 21:56:37 UTC, Atila Neves wrote: I feel dirty if I write `__gshared`. I sneeze when I read it. But everytime I try and use `shared` I get trouble for it. TIL that if I want a struct to be both `shared` and not, destructors are out of the way. Because while

Re: shared: Has anyone used it without a lot of pain?

2017-04-05 Thread Guillaume Piolat via Digitalmars-d
On Wednesday, 5 April 2017 at 13:18:26 UTC, Andrea Fontana wrote: On Tuesday, 4 April 2017 at 21:56:37 UTC, Atila Neves wrote: I feel dirty if I write `__gshared`. I sneeze when I read it. But everytime I try and use `shared` I get trouble for it. [...] Atila

Re: shared: Has anyone used it without a lot of pain?

2017-04-05 Thread Andrea Fontana via Digitalmars-d
On Tuesday, 4 April 2017 at 21:56:37 UTC, Atila Neves wrote: I feel dirty if I write `__gshared`. I sneeze when I read it. But everytime I try and use `shared` I get trouble for it. [...] Atila https://p0nce.github.io/d-idioms/#The-truth-about-shared

Re: shared: Has anyone used it without a lot of pain?

2017-04-05 Thread Dukc via Digitalmars-d
On Tuesday, 4 April 2017 at 21:56:37 UTC, Atila Neves wrote: The reason why what I was trying to do isn't possible is obvious in hindsight, but it's still annoying. So either code duplication or mixins, huh? template flag parameter for the struct for being shared or not? I may well be

Re: shared: Has anyone used it without a lot of pain?

2017-04-04 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, April 04, 2017 21:56:37 Atila Neves via Digitalmars-d wrote: > I feel dirty if I write `__gshared`. I sneeze when I read it. Well, it was designed with C global variables in mind, and it's pretty risky to use it for anything else, though you can get away with it if you're careful.

shared: Has anyone used it without a lot of pain?

2017-04-04 Thread Atila Neves via Digitalmars-d
I feel dirty if I write `__gshared`. I sneeze when I read it. But everytime I try and use `shared` I get trouble for it. TIL that if I want a struct to be both `shared` and not, destructors are out of the way. Because while constructors are easy because we can have more than one: struct Foo