GithubHelp home page GithubHelp logo

slaurin / thread_pool_cpp17 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fbastos1/thread_pool_cpp17

0.0 1.0 0.0 11 KB

Thread Pool implementation in C++17

License: MIT License

C++ 100.00%

thread_pool_cpp17's Introduction

thread_pool_cpp17

C++17 implementation of a thread pool. Requires some C++17 features (see Required language features).

Sample usage

#include <iostream>
#include <vector>
#include "threadpool.h"

int multiply(int x, int y) {
    return x * y;
}

int main() {
    thread_pool pool(4);
    std::vector<std::future<int>> futures;

    for (const int &x : { 2, 4, 7, 13 }) {
        futures.push_back(pool.execute(multiply, x, 2));
    }

    for (auto &fut : futures) {
        std::cout << fut.get() << std::endl;
    }

    return 0;
}

Required language features (C++14 and newer only)

std::is_invocable, std::is_invocable_v (C++17 feature)
std::invoke_result (C++17 feature)
move-only lambda capture (C++14 feature)

Compilation flags

This may not compile without an explicit C++17 flag (depending on your compiler). If there are errors, double check the flags you pass to your compiler.

clang: -std=c++17
gcc: -std=c++17
msvc: /std:c++17

thread_pool_cpp17's People

Contributors

fbastos1 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.