Sen API
Sen Libraries
Loading...
Searching...
No Matches
work_queue.h
Go to the documentation of this file.
1// === work_queue.h ====================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_CORE_OBJ_DETAIL_WORK_QUEUE_H
9#define SEN_CORE_OBJ_DETAIL_WORK_QUEUE_H
10
11// sen
15
16// std
17#include <memory>
18
19namespace sen::impl
20{
21
22// Represents a unit of work.
23using Call = sen::std_util::move_only_function<void()>;
24
25class WorkQueueImpl;
26
29class WorkQueue final
30{
31public:
32 SEN_NOCOPY_NOMOVE(WorkQueue)
33
34public:
35 WorkQueue(std::size_t maxSize, bool dropOldest);
36 ~WorkQueue();
37
38public:
40 void enable();
41
43 void disable();
44
46 void clear();
47
49 void push(Call&& call, bool force);
50
52 [[nodiscard]] bool executeAll();
53
55 void waitExecuteOne();
56
58 void waitExecuteAll(const Duration& timeout);
59
61 void setOnDropped(std_util::move_only_function<void(const Call&)>&& callback);
62
64 [[nodiscard]] std::size_t getCurrentSize() const noexcept;
65
66private:
67 std::unique_ptr<WorkQueueImpl> pimpl_;
68};
69
70} // namespace sen::impl
71
72#endif // SEN_CORE_OBJ_DETAIL_WORK_QUEUE_H
Here we define a set of template meta-programming helpers to let the compiler take some decisions bas...
@ force
Definition unit.h:40
detail::MoveOnlyFunctionImpl< FwdArgs... > move_only_function
Definition move_only_function.h:256