GithubHelp home page GithubHelp logo

corvusoft / runloop Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 1.0 100 KB

Event processing loop for scheduling and coordinating asynchronous work; fire and forget.

Home Page: http://www.corvusoft.co.uk

License: Other

CMake 14.59% C++ 84.04% Shell 1.37%
async-programming asynchronous asyncio runloop thread-pool

runloop's People

Contributors

ben-crowhurst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nobilisnc

runloop's Issues

Daisy chaining tasks.

Runloop loop;
loop->launch( task1, "my-key" );
loop->launch_after( "my-key", task2 );

Document API

    //document that if a task is already executing it will complete before sleeping.
    //if a task wants to determine at runtime if it is suspended it may call is_suspended( );
    void RunLoop::suspend( void )
    // Note if you have tasks with unmet conditions via launch_if and/or launch_at. the loop::wait method
    // will block until successful completion of all tasks.
    //This function may block for longer than timeout_duration due to scheduling or resource contention delays.
    error_code RunLoop::wait( const milliseconds& duration )

//cancel tasks that have not yet executed.
void RunLoop::cancel( const string& key )

    /*
     * Note that when a sighandler is running you may miss other signals of the same number until
     * your handler has finished. that is to state a signal handler for a specific signum is
     * no able to run consecutively, you can't have the same handler running concurrently.
     * if you throw an exception from a handler you will need to reschedule the handler yourself!
     */
    void RunLoop::launch_on( const signal_t value, const function< error_code ( void ) >& task, const string& key )
    void RunLoop::set_log_handler( const function< error_code ( const string&, const error_code&, const string& ) >& value )
    {
        suspend( ); //document me on api, this is bad unless suspend waits fro all takes to sleep.
        m_pimpl->log_handler = value;
        resume( );
    }

    void RunLoop::set_error_handler( const function< error_code ( const string&, const error_code&, const string& ) >& value )
    {
        suspend( ); //doc me, this is bad unless suspend waits fro all takes to sleep.
        m_pimpl->error_handler = value;
        resume( );
    }

launch until

Runloop loop;
loop->launch_in( seconds( 5 ), task );

This will launch a task in 5 seconds and can be rescheduled by sending back an appropriate code, EAGAIN?

Extract logger.

Place the logger into its own project as its a commonly shared resource.

Flush pending tasks.

The ability to flush a number of pending tasks without calling start.

auto loop = make_shared< RunLoop >( );
loop->launch( ... );
loop->launch( ... );
loop->digest( 1 );

Ability to launch tasks without returning an error_code

To reduce code and for those tasks where you just don't care.

void launch( const std::function< std::error_code ( void ) >& task, const std::string& key = "" );

void launch( const std::function< void ( void ) >& task, const std::string& key = "" );

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.