I'm porting some go code to D

Rory McGuire rjmcguire at gmail.com
Wed Sep 18 13:20:11 PDT 2013


I've made the scheduler a bit more inteligent and the channel
implementation is now backed by a lock free queue.
https://github.com/rjmcguire/goport/blob/tip/wrapper2.d for a example using
libev

https://github.com/rjmcguire/goport/blob/tip/goroutine.d for the "go"
routines

https://github.com/rjmcguire/goport/blob/tip/channel.d channel
implementation, the channel still has a read lock because I didn't like
looping wasting cpu cycles/battery, I may change this to use the same loop
as the select(...) expression with a timeout that backs off.

https://github.com/rjmcguire/goport/blob/tip/concurrentlinkedqueue.d queue
implementation


there is a problem with the file EV handler in that it can get spurios READ
events and I can't seem to set it to non-blocking.

The select(...) implementation and usage is quite interesting because it
works very much like Go's select statement.


On Mon, Aug 26, 2013 at 1:28 AM, Rory McGuire <rjmcguire at gmail.com> wrote:

> Awesome thanks, thought what I did there was dodgy. It was really weird
> when this() started multiple schedulers at least now I see the obvious
> reason.
>
> BTW: gist is at: https://gist.github.com/rjmcguire/6336931
>
> Could someone point me at the correct linked list to use inside the
> channel. I'd prefer to use a range container of some kind if it exists in
> the std lib. I tried SList and had a bad experience hence the custom
> implementation.
>
>
>
> On Mon, Aug 26, 2013 at 1:21 AM, Timon Gehr <timon.gehr at gmx.ch> wrote:
>
>> On 08/26/2013 12:55 AM, Rory McGuire wrote:
>>
>>>
>>> shared chan!Fiber scheduler; // channel contains Fibers waiting for
>>> their time slice
>>> static this () {
>>>      if (scheduler is null) {
>>>
>>
>>
>> You want 'shared static this' instead to avoid a race condition.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20130918/4eb56020/attachment.html>


More information about the Digitalmars-d-announce mailing list