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 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.
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.
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 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.)
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)
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.
Basically, deadline is a context-free timeout.
[1] https://githu.com/mashape/kong
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...