Coder Social home page Coder Social logo

siddiqsoft / asynchrony-lib Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 119 KB

Classes to allow you to build asynchrony in your applications using standard C++ jthread, semaphore, deque

Home Page: https://siddiqsoft.github.io/asynchrony-lib/

License: BSD 3-Clause "New" or "Revised" License

C++ 100.00%
asynchronous-programming cpp cpp20 nuget periodic-invocation thread-pool worker-pool

asynchrony-lib's People

Contributors

abdulkareem-siddiq avatar

asynchrony-lib's Issues

Rename the structs

The use of names 'basic_*' is confusing with the std naming.
Rename the structs to avoid any confusion.

simple_pool does not handle structs

Structs with implicitly deleted copy constructors fail to compile. There is a needless copy during pop from queue.

The compiler reports no appropriate default constructor available.
The culprit is here in the thread worker loop code:

    if (signal.try_acquire_for(signalWaitInterval)) {
        // Guard against empty signals which are terminating indicator
        if (!items.empty() && !st.stop_requested()) {
            T item;

            { // scope lock to pull item from the deque
                std::unique_lock<std::shared_mutex> myWriterLock(items_mutex);
                item = items.front();
                items.pop_front();
            } // end of lock
            // Delegate to the callback outside the lock
            callback(item);
        }
    }

The fact that we use T item; requires that the object be default constructible whereas our only real requirement is the object type be move constructible.

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.