Giter Club home page Giter Club logo

coasync4cpp's Introduction

coasync4cpp Project

coasync4cpp allows to write async code without callbacks using async/await/task! For C++11!

async/await

This library let you use the async/await pattern, known from c#, for your c++ or qt projects. You can define any method as 'async' and than make use of the await or Task<> keywords of the library.

Lets see in an simple example, what the library can do for you. In this QT-based example, we make use of QFuture and QFutureWatcher to await the result of an operation within the thread pool:

 // Instantiate the objects and connect to the finished signal.
 MyClass myObject;
 QFutureWatcher<int> watcher;
 connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished()));
 
 // Start the computation.
 QFuture<int> future = QtConcurrent::run(...);
 watcher.setFuture(future);

this can now be replaced by a single line of code:

 int result = await QtConcurrent::run(...);

You save an complete callback, you have not longer to manage the QFuture/QFutureWatcher things. You simply write your code from top to bottom. As it is with synchronous code.

QtConcurrent::run returns here an QFuture. This is called an Awaitable.

Awaitables

An operation, that is already running and promises to you to deliver an result in the future is called an 'Awaitable'.

coasync4cpp currently supports a bunch of Awaitables:

  • boost::future
  • QFuture
  • Task<>

We can await an Awaitbale using the Task<> object or await keyword. But, these awaits are only allowed within an asyncronous execution context. To create such an context, we use Task Factories.

TaskFactories

Thread Dispatcher

How to start

GitHub

coasync4cpp issues

If you spot a bug or want to brainstorm a potential new feature, then please raise an issue in our main GitHub project (helgebetzinger/coasync4cpp); likewise if you have developed a cool new feature or improvement in your coasync4cpp fork, then send us a pull request!

For the wiki and readme.me, we use markdown syntax. We have good experiences using this online editor.

Documentation

Community

http://stackoverflow.com/

If you found no answer here, then don't by shy and ask the community. Tag your question with an 'coasync4cpp' tag.

Email

[email protected]

If you want to talk directly to us (e.g. about a commercially sensitive issue), email is the easiest way.

coasync4cpp's People

Contributors

helgebetzinger avatar

Watchers

James Cloos avatar  avatar

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.