News for hackers. Stuff that matters.
Re:Building a concurrent TCP server with libmill by abcd_f on Saturday July 25, 2015 @04:03PM (#9948802)
If I understand correctly, this is a framework for non-preemptive cooperative multitasking whereby provided API functions serve as yield points. Pretty much what Windows API was before NT/2000. Not exactly a co-routine library, at least not in a conventional definition of co-routines.
Re:Building a concurrent TCP server with libmill by rumcajz on Saturday July 25, 2015 @04:07PM (#9948814)
Yes, that's exactly what it is. But it also matches wikipedia's difinition of coroutine: "Coroutines are computer program components that generalize subroutines for nonpreemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations."
Re:Building a concurrent TCP server with libmill by btrask on Saturday July 25, 2015 @04:54PM (#9948968)
Fibers and coroutines are different uses for the same thing. If you schedule your coroutines based on the kernel scheduler, they're fibers. If you jump between fibers explicitly, they're coroutines.
Re:Building a concurrent TCP server with libmill by rumcajz on Saturday July 25, 2015 @05:04PM (#9949004)
Using that definition, libmill is definitely coroutine-based. It does the scheduling itself.
Re:Building a concurrent TCP server with libmill by btrask on Saturday July 25, 2015 @05:19PM (#9949056)
I think it's mainly a fiber library, actually. The TCP and channel functions yield and resume automatically based on when the underlying operation blocks.

They have yield(), but I don't see the opposite, the ability to explicitly resume a stopped context.

Edit: for a "pure" coroutine library, I'd recommend libco from BSNES. It only has 4 functions: active, create, switch and delete. I wrote a fiber library using libco plus libuv, which was fairly easy.

https://web.archive.org/web/20140209005854/http://byuu.org/p... (unfortunately he still hasn't rebuilt his site)

Re:Building a concurrent TCP server with libmill by wcummings on Saturday July 25, 2015 @01:09PM (#9948203)
Can anyone explain the deadlines vs timeout distinction?
Re:Building a concurrent TCP server with libmill by rumcajz on Saturday July 25, 2015 @01:15PM (#9948218)
Timeout: finish in 10 seconds.

Deadline: finish at 7:15:35PM.

The advantage of deadlines is that you can define a fixed deadline and then re-use it for any number of calls, without having to subtract the time already spent in previous calls.

Re:Building a concurrent TCP server with libmill by obstinate on Saturday July 25, 2015 @02:13PM (#9948431)
Yes, and if you set the deadline on the client, the server knows (subject to its time skew) when the request needs to finish. With a timeout, you have to factor in latency, which is necessarily error prone.

Basically, deadline is a context-free timeout.

Re:Building a concurrent TCP server with libmill by huhtenberg on Saturday July 25, 2015 @05:54PM (#9949174)
... unless, of course, it's on the wall clock scale, in which case changing machine time will invalidate all your deadlines. Just need to be careful to use something like 'ticks from the last boot' rather than UTC time.
Re:Building a concurrent TCP server with libmill by obstinate on Saturday July 25, 2015 @07:05PM (#9949383)
In competently run environments, wall clock changes are smeared. :) there is no way to use ticks since last boot, since the server will have a different value from the client.
Re:Building a concurrent TCP server with libmill by Retr0spectrum on Saturday July 25, 2015 @03:18PM (#9948652)
This looks very useful. Would this be a good base to make something like a custom HTTP proxy with?
Re:Building a concurrent TCP server with libmill by pantalaimon on Saturday July 25, 2015 @06:32PM (#9949294)
Are the coroutines scheduled across cores or do they all run in the same thread?
Re:Building a concurrent TCP server with libmill by rumcajz on Sunday July 26, 2015 @12:42AM (#9950172)
Same thread.
Re:Building a concurrent TCP server with libmill by jkarneges on Saturday July 25, 2015 @09:59PM (#9949821)
Very cool. Any idea how this compares to lthread?
Re:Building a concurrent TCP server with libmill by culo on Sunday July 26, 2015 @12:14AM (#9950114)
Would be cool to add KONG [1] to libmill to secure and monitor API traffic.

[1] https://githu.com/mashape/kong

Re:Building a concurrent TCP server with libmill by hassy on Sunday July 26, 2015 @01:21AM (#9950231)
This comment doesn't even make sense.

Kong is a cool product, but Kong spam from a couple of accounts [1] on HN is getting tiresome. (Maybe it's just that I look through the comments of most stories to do with APIs.)

https://hn.algolia.com/?query=mashape%2Fkong&sort=byPopulari...