Coder Social home page Coder Social logo

picoasync's People

Contributors

funmiles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mfkiwl devklee

picoasync's Issues

Add a CPU yield awaitable.

A purely coroutine based multi-tasking system needs all tasks to be good citizen of the cooperative multi-tasking system, yielding the CPU to other tasks in a periodic manner, enabling long running compute intensive tasks to run while not stopping other tasks from operating.
A yield awaitable object is a clean way of achieving this goal. It can be awaited periodically in long running loops:

task<> do_some_long_computation(int iterationCount, auto &&operation, priority myPriority)
{
    for (int i = 0; i < iterationCount; ++i) {
         // Perform one iteration's work
         operation(i);
         // Yield the CPU, signaling the queueing system our priority (optional argument)
         co_await cpu::yield(myPriority); 
     }
}

An example of such use is for the SSD1306 code. Filling the OLED screen buffer to print text can take tens of thousands of cycles.
The routine performing this operation should be capable of yielding so that time-critical operations can take place.

Definitions in headers cause linker issues with multiple compilation units

If you have multiple compilations units using the library, you get "multiple definitions" linker errors because of the functions defined in the header files, namely events.h. I guess a solution could be to inline those as well.

Off topic:
Great project! I'm glad I ran into this. I was looking for precedence to programming RP2040 async style. I hope the library catches on and keeps getting developed and maintained.

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.