Giter Club home page Giter Club logo

Comments (5)

Xudong-Huang avatar Xudong-Huang commented on May 18, 2024

for a given coroutine/scope limit parallelism to 1

this is possible with the following configuration

may::config().set_workers(1).set_io_workers(0);

pin a coroutine/scope to a specific thread (UI thread for example)

no, currently may doesn't support coroutine thread affinity.

from may.

alkis avatar alkis commented on May 18, 2024

Wouldn't:

may::config().set_workers(1).set_io_workers(0);

set parallelism to 1 across all coroutines?

What I want to do is to have a function:

fn doStuff() {}

and all coroutines that run through it have constrained parallelism.

from may.

Xudong-Huang avatar Xudong-Huang commented on May 18, 2024

can Mutex/Semphore fullfill the requirement?

from may.

alkis avatar alkis commented on May 18, 2024

It will do the work but it seems to me that it does more work than necessary.

The scheduler already does the synchronization (fences/etc) necessary when a coroutine switches from one thread to another. If for example it happens that most of the time doStuff() is running with 1 parallelism, having a scheduler constraint will amount to an atomic increment and decrement. Assuming the doStuff() is not contended, this will be super fast.

Mutex seems much heavier than that. Perhaps I am missing something?

from may.

Xudong-Huang avatar Xudong-Huang commented on May 18, 2024

The sync primitives used in coroutine context doesn't involve system calls, and they are just running in user space which is fast.

from may.

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.