SergejJurecko / easyfibers

easyfibers is a closure-less couroutine library for executing asynchronous tasks as painlessly as possible.
Apache License 2.0
6 stars 0 forks source link

How to define our own fibers #1

Open antoyo opened 7 years ago

antoyo commented 7 years ago

Hello. I wonder how to define a custom fiber types, for instance, something similar to futures' mpsc. Is it something we can do with easyfibers now? Or is it planned for later? Thanks.

SergejJurecko commented 7 years ago

I don't quite understand what you mean. Can you give me a use case what you want to achieve?

SergejJurecko commented 7 years ago

The API will surely change in the near future as I start to actually use the lib. Right now the focus was getting the basic functionality done.

Different fiber types are done through instantiating new Runner's with different parameters.

easyfibers as opposed to futures/tokio (as I see it) does not aim to have everything running in fibers. I am very hesitant to do fiber-fiber communication other than the parent-child relationship as it exists now.

antoyo commented 7 years ago

My use case is to have some kind of asynchronous queue of messages so that one fiber (or any other code actually) can send messages into this queue and have some other code to execute when this queue is polled later and contains a message.

SergejJurecko commented 7 years ago

You create a runner, then call one of the new_ functions to start processing on a fiber. Right now all of them are either tied to a socket or a timer. I can add one that is not tied to any of those. It is purely cooperative multitasking however. A fiber stops being executed when issuing a blocking call like write/read or calls join_main.

SergejJurecko commented 7 years ago

On master there is a new_processor now. As far as I can see the basic building blocks are there. Or is there something missing?

antoyo commented 7 years ago

I'll test that. Thanks.