GithubHelp home page GithubHelp logo

cerkiewny / aconcurrent Goto Github PK

View Code? Open in Web Editor NEW

This project forked from e-fever/aconcurrent

0.0 1.0 0.0 53 KB

Enhanced QtConcurrent based on AsyncFuture

License: Apache License 2.0

C++ 95.40% QMake 1.70% CMake 2.90%

aconcurrent's Introduction

Enhanced QtConcurrent based on AsyncFuture

AConcurrent contains functionality to support concurrent execution of program code. It is an enhanced version of QtConcurrent.

Installation

qpm install net.efever.aconcurrent

API

    #include <aconcurrent.h>

QFuture AConcurrent::runOnMainThread(Functor functor)

Run a function on the main thread and returns a QFuture to represent the result of the function. If the current thread is the main thread, it will be executed in next tick.

Example

auto worker = [=]() {

  // processing
  QFuture<int> future = AConcurrent::runOnMainThread([=]() {
    // Save the result on main thread
    return 0; // no error
  });
  AConcurrent::await(future); // future.waitForFinished();
};

QtConcurrent::run(worker);

QFuture AConcurrent::timeout(int value)

Returns a QFuture<void> which will be completed after msec specified by value.

QFuture AConcurrent::mapped(Sequence sequence, Functor worker)

Calls function once for each item in sequence and return a future with each mapped item as a result. It is similar to the QtConcurrent::mapped() but this version supports lambda function. The returned QFuture is cancelable.

QFuture AConcurrent::blockingMapped(Sequence sequence, Functor worker)

AConcurrent::await(future)

Wait until the input future is finished while keeping the event loop running.

*Pipeline AConcurrent::pipeline(QThreadPool pool, );

aconcurrent's People

Contributors

benlau avatar

Watchers

James Cloos 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.