-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Loic Reyreaud <loic.reyreaud@epita.fr>
- Loading branch information
Loic Reyreaud
committed
Aug 19, 2018
1 parent
c6cc9ee
commit 48ad419
Showing
3 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Getting Started | ||
=============== | ||
|
||
Install | ||
------- | ||
|
||
First, you need the :code:`threadpool.hpp` header file. You can simply copy it | ||
into your source tree, or you can install it. To install run the following | ||
commands: | ||
|
||
.. code-block:: bash | ||
$ git clone git@github.com:reyreaud-l/threadpool.git | ||
$ cd threadpool | ||
$ mkdir build | ||
$ cd build | ||
$ cmake .. | ||
$ make install | ||
This will make the header available in your system. | ||
|
||
First Pool | ||
---------- | ||
|
||
Let's see a simple use of the threadpool | ||
|
||
.. code-block:: c++ | ||
|
||
#include <iostream> | ||
#include <threadpool/threadpool.hpp> | ||
|
||
int main() | ||
{ | ||
ThreadPool mypool(1); | ||
auto task = mypool.run([]() { std::cout << "Hello there!" << std::endl; }); | ||
std::cout << "General Kenobi!" << std::endl; | ||
task.wait(); | ||
} | ||
|
||
|
||
Note that we instantiate a task and wait for it to make sure the task is ran. | ||
With such a short program, it is possible that mypool will be deleted before a | ||
working is woke up to pick the task and run it. Waiting for the result ensure | ||
the task is ran. It is possible to use this syntax if you don't care about the | ||
return value or want to wait for a task to end | ||
|
||
.. code-block:: c++ | ||
|
||
... | ||
mypool.run([]() { std::cout << "Hello there!" << std::endl; }); | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ Welcome to threadpool's documentation! | |
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
threadpool | ||
getting_started | ||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.