AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
flux.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <functional>
23#include <future>
24#include <mutex>
25
26
27namespace anch {
28
50 template<typename... T>
51 class Flux {
52
53 // Attributes +
54 private:
56 bool _con;
57
59 std::promise<std::function<void(const T&...)>> _pcon;
60
62 std::shared_future<std::function<void(const T&...)>> _consumer;
63
65 bool _fin;
66
68 std::promise<std::function<void()>> _pfin;
69
71 std::shared_future<std::function<void()>> _finalizer;
72
74 bool _err;
75
77 std::promise<std::function<void()>> _perr;
78
80 std::shared_future<std::function<void()>> _errorHandler;
81
83 std::mutex _mutex;
84 // Attributes -
85
86 // Constructors +
87 public:
92 // Constructors -
93
94 // Destructor +
95 public:
100 // Destructor -
101
102 // Methods +
103 public:
114 void ready();
115
122 void push(const T&... object);
123
128 void finalize();
129 // Methods -
130
131 // Accessors +
132 public:
140 void setConsumer(std::function<void(const T&...)> consumer);
141
149 void setFinalizer(std::function<void()> finalizer);
150
158 void setErrorHandler(std::function<void()> errorHandler);
159 // Accessors -
160
161 };
162
163}
164
165#include "impl/flux.hpp"
void setConsumer(std::function< void(const T &...)> consumer)
void push(const T &... object)
void setFinalizer(std::function< void()> finalizer)
void ready()
void finalize()
void setErrorHandler(std::function< void()> errorHandler)
AnCH framework base namespace.
Definition app.hpp:30