Giter Site home page Giter Site logo

Evaluate using coroutine::Context instead of coroutine::Coroutine. Maybe there are some gains by not using global scheduling etc. about mioco.pre-0.9 HOT 22 CLOSED

dpc avatar dpc commented on June 16, 2024
Evaluate using coroutine::Context instead of coroutine::Coroutine. Maybe there are some gains by not using global scheduling etc.

from mioco.pre-0.9.

Comments (22)

zonyitoo avatar zonyitoo commented on June 16, 2024

I am planning on refactor the coroutine-rs library to work just like coroutine in Boost. That would provide more flexible APIs for you to define what user could do in your callback function.

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

I don't know how boost one works, but what we need in essence is really a context state for each handler ability to switch to it and and get back. Alternatively an exposed scheduler API. So I can have one scheduler for each mioco server instance, and potentially user being able to use coroutines withing handlers, but without interfering with a mioco server scheduler state.

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

Maybe you can put the Scheduler into a thread local structure.

a context state for each handler ability to switch to it and and get back

I think this is in the feature clonable-handler.

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

I thought clonable handler just gives me an ability to clone Closure handler. Which I already use.

I want to have more Schedulers on the same thread.

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

I don't know what exactly you want. Maybe I should look deep into your source code.

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

I don't think source will tell much. It's just, I would like to it to be possible to have a scheduler state that cannot be interfered from outside.

In mioco we have server, that is scheduling coroutines (handlers). It depends on coroutine_handle.resume() jumping into handler, and coroutine::block() in the handler to get back to server. If handlers code will start using coroutines on it's own, then there might be more runnable coroutines and then it all falls appart: eg. block() will not get back to the server code, but instead resume some other coroutine that did yield() before or something similar.

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

Ok, I see. So you want to have a scheduler. Maybe you could redefine the spawn function to restrict those new spawned coroutines to be managed inside the scheduler.

On the other hand, you could also reverse your architecture, which means that a server just one of the coroutines that running on the scheduler. I think you may be interested in this repo: https://github.com/zonyitoo/simplesched

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

If I'm to work on this, I think I'm just going to get a context switch functionality.

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

So, maybe I should expose the context API?

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

That would be awesome. I've been looking into https://github.com/rustcc/coroutine-rs/blob/master/src/context.rs on how to plug mioco to it, but that's it.

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

Please try to use this crate: https://github.com/zonyitoo/context-rs
Happy hacking :)

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

Awesome! Thanks!

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

context-rs was exactly what I needed!

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

You may try the feature-fnbox branch.

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

@zonyitoo : What's the difference? What does it give me? :) . I see that "Send" from initfn is gone.

You want me to try to see if it works OK?

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

This version uses the latest feature FnBox in the libstd. So I can get rid of the Thunk and Send trait.

Please try whether it works Ok, I want to merge it into the master branch.

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

Any reason you use internal libc? I thought we're supposed to use crates.io version, no?

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

Just for historical reason, let me make some updates.

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

Ready. Branch context-feature-fnbox. It works here. I like the fact that I don't have to fake Send now. But the additional feature-s will prevent us from working on anything but nightly for a while.

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

I can merge it as soon as you make it available on crates.io so it builds for everyone.

from mioco.pre-0.9.

zonyitoo avatar zonyitoo commented on June 16, 2024

I already merge it to the master branch, but since the simd crate is not ready for pushing to crates.io, I have to wait ...

from mioco.pre-0.9.

dpc avatar dpc commented on June 16, 2024

No hurry. :)

from mioco.pre-0.9.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.