Fiber and Thread Communication

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 8 14:42:53 PDT 2016


On Friday, 8 April 2016 at 20:25:11 UTC, Ali Çehreli wrote:
> On 04/08/2016 01:16 PM, Dicebot wrote:
>> On Friday, 8 April 2016 at 19:46:17 UTC, tcak wrote:
>>> On Friday, 8 April 2016 at 15:33:46 UTC, Dicebot wrote:
>>>> On Friday, 8 April 2016 at 14:08:39 UTC, Nordlöw wrote:
>>>>> So a TId can represent either a thread or a fiber?
>>>>
>>>> AFAIR, yes (I haven't used std.concurrency in a long while, 
>>>> telling
>>>> all from memory only).
>>>
>>> yes what? Thread or Fiber.
>>
>> Yes both :) Tid represent abstract execution context, with no
>> implications about underlying executor.
>
> Thanks Dicebot. I don't think the included 
> std.concurrency.FiberScheduler has support for message passing 
> because FiberScheduler.spawn does not return a Tid. If so, I 
> don't see how it's possible to send messages between fibers.
>
> Ali

Looks like a (funny) oversight. Note that you get it for get 
fiber via 
https://github.com/D-Programming-Language/phobos/blob/master/std/concurrency.d#L1337 (and FiberScheduler specifically extends Fiber to add ThreadInfo to it) but there is no clear way to pass that info to spawn host. I have a feeling that if that code is patched to simply provide Tid, message passing will just magically work. Needs to be checked though.


More information about the Digitalmars-d-learn mailing list