

Lthread - A coroutine lib with multicore support - halayli
http://github.com/halayli/lthread

======
dkersten
Just the other day I started sketching out plans for something similar to run
on top of Intel's Threading Building Blocks' task scheduler for a personal
project I'm working on.

What I'm basically looking for is low overhead lightweight threads that can be
run in parallel in a pool of real heavy-weight threads. Coroutines with
multicore, as this library does, should do exactly what I want and I can avoid
the "lthreads cannot block or other lthreads in that pthread will not run"
rule since in my codebase I can replace blockiing calls with ones which would
yield so useful work can continue.

The only feature that I would also like but don't know if lthread has is being
able to move lthreads between schedulers (something like TBB's work stealing
would be ideal).

~~~
halayli
Unfortunately, as of now you cannot move an lthread from one scheduler to
another but it can be implemented. May I ask why you want to do that?

I am working on lthread_compute for compute intensive tasks which will offload
the work to a worker pool and resume the function once it's done.

~~~
dkersten
Well, what I basically want is a TBB-like task scheduler, but with the ability
to pause and resume tasks without running them to completion (to allow tasks
to "block" - the condition variables in lthread are perfect for this). To do
this in plain TBB, I would have to split the task into multiple smaller tasks,
since there is no way to suspend a task but have the scheduler still process
other tasks and then later resume the task mid-function.

I want to be able to move tasks to other threads so that if a thread runs out
of work early it can _steal_ work from a busy thread.

Unfortunately I just realised that for the project I have in mind I won't be
able to use lthread as I won't be able to release it under the GPL, but I
really like what I see so far and I also really like the sound of
lthread_compute, so I am definitely keeping an eye on the project and will
likely make use of it in the future.

~~~
halayli
Ah, that's unfortunate.

I'll be implementing lthread_compute during the holidays. Keep an eye on that.
:)

