Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fosterbrereton committed Jun 10, 2017
2 parents 4c456a7 + 71295cd commit 7a60510
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 17 deletions.
27 changes: 19 additions & 8 deletions libraries/concurrency/channel/process/process_example.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <atomic>
#include <iostream>
#include <thread>

#include <stlab/concurrency/channel.hpp>
#include <stlab/concurrency/default_executor.hpp>
Expand Down Expand Up @@ -35,17 +37,26 @@ struct adder

int main() {
sender<int> send;
receiver<int> receiver;
receiver<int> receiver;
std::tie(send, receiver) = channel<int>(default_executor);

auto calculator = receiver | adder{} |
[](int x) { std::cout << x << '\n'; };
std::atomic_bool done{false};

auto calculator = receiver |
adder{} |
[&_done = done](int x) { std::cout << x << '\n';
_done = true;
};

receiver.set_ready();

while (true) {
int x;
std::cin >> x;
send(x);
}
send(1);
send(2);
send(3);
send(0);

// Waiting just for illustrational purpose
while (!done) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
3 changes: 2 additions & 1 deletion libraries/concurrency/channel/receiver/executor/executor.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ scope: stlab
pure-name: executor
defined-in-header: stlab/concurrency/channel.hpp
declaration: executor()
description: Constructs a new executor object
brief: Constructs a new executor wrapper object
description: Constructs a new executor wrapper object
entities:
- kind: methods
list:
Expand Down
1 change: 1 addition & 0 deletions libraries/concurrency/channel/receiver/executor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pure-name: executor
defined-in-header: stlab/concurrency/channel.hpp
git-link: https://github.com/stlab/libraries/blob/develop/stlab/concurrency/channel.hpp
declaration: struct executor
brief: Executor wrapper class
description: This class has only one purpose, to encapsulate an executor to be piped to a `receiver<T>`
dtor: default
example: executor_example.cpp
Expand Down
2 changes: 1 addition & 1 deletion libraries/concurrency/channel/receiver/operator_pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ scope: receiver
pure-name: operator|
defined-in-header: stlab/concurrency/channel.hpp
declaration: operator|()
brief: Creates a new receiver with the given process attached downstream.
brief: Attaches a new process to the channel.
description: Creates a new receiver, attaches the given process as downstream to it and returns this new receiver. The new receiver inherits the executor from its upstream receiver if not an alternative executor is attached. In case that `T` of `receiver<T>` is a move only type, repeated calls of this operator overwrite the previous attached downstream channel.
example: operator_pipe_example.cpp
entities:
Expand Down
3 changes: 2 additions & 1 deletion libraries/concurrency/channel/receiver/set_ready.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ scope: receiver
pure-name: set_ready
defined-in-header: stlab/concurrency/channel.hpp
declaration: set_ready
description: Sets this receiver ready to receive values.
brief: Sets the receiver ready to receive values.
description: Sets the receiver ready to receive values.
example: set_ready_example.cpp
entities:
- kind: methods
Expand Down
1 change: 1 addition & 0 deletions libraries/concurrency/channel/sender/operator().md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ scope: sender
pure-name: operator()
defined-in-header: stlab/concurrency/channel.hpp
declaration: operator()
brief: Sends a new value into the channel
description: Sends a new value into the channel
example: call_operator_example.cpp
entities:
Expand Down
2 changes: 1 addition & 1 deletion libraries/concurrency/channel/zip.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: stlab::zip
tags: [library]
scope: stlab
pure-name: zip
brief: Creates a future that zips all passed arguments
brief: It creates a process that zips all passed arguments and returns a receiver.
annotation: template function
example: zip_example.cpp
entities:
Expand Down
3 changes: 2 additions & 1 deletion libraries/concurrency/executor/default_executor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: stlab::default_executor
pure-name: default_executor
defined-in-header: executor/concurrency/default_executor.hpp
declaration: struct default_executor
description: Executes functions on the system's thread pool
brief: Interface to the system's thread pool
description: Executes functions on the system's thread pool. On MacOS, Windows, Emscripten and PNaCl the OS integrated thread pool is the base of this class. For other OS an custom thread pool is provided.
member-types:
- type: result_type
definition: void
Expand Down
2 changes: 1 addition & 1 deletion libraries/concurrency/executor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: library
title: Executors
tags: [library]
brief: Executors. They execute.
brief: A collection of executors with different strategies to run tasks.
description: |
Executors provide a means of running functions using different execution policies via a consistent interface.
---
6 changes: 5 additions & 1 deletion libraries/concurrency/future/future/recover.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ scope: future
pure-name: recover
defined-in-header: stlab/concurrency/future.hpp
declaration: recover()
description: Creates a recoverable continuation on the current object.
brief: Creates a recoverable future on the current object.
description: Since the futures are value based, the recover method should be used to do the error handling.
example: recover_example.cpp
entities:
- kind: methods
Expand Down Expand Up @@ -45,4 +46,7 @@ entities:
description: Executor which is used to schedule the resulting task
- name: f
description: Callable object that implements the `recover()` function. Its parameter must be of type of this `future<T>` instance.
- kind: result
description: It returns the recoverable future

---
2 changes: 1 addition & 1 deletion libraries/concurrency/future/future/then.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tags: [library]
scope: future
pure-name: then
defined-in-header: stlab/concurrency/future.hpp
brief: Creates a continuation
brief: Creates a continuation on the current future.
declaration: then()
example: [then_continuation_example.cpp, then_split_example.cpp]
description: |
Expand Down
7 changes: 6 additions & 1 deletion libraries/concurrency/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ description: |
Since one can create with futures only graphs for single use, this library provides as well channels. With these channels one can build graphs, that can be used for multiple invocations.
---

### Source Code

The source code is hosted on [github](https://github.com/stlab/libraries).


{% include example_table.html %}

### Requirements
Expand All @@ -17,4 +22,4 @@ description: |
* boost 1.60.0 (optional, variant and test for executing the UnitTests)

### Authors
Sean Parent, Felix Petriconi
Sean Parent, Foster Brereton, Felix Petriconi

0 comments on commit 7a60510

Please sign in to comment.