vitrio 0.3.1
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
counting_completion.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/concurrency/completion.hpp>
6#include <vitrio/concurrency/completion_notifier.hpp>
7#include <vitrio/export.hpp>
8#include <vitrio/platform.hpp>
9
10#include <cstddef>
11#include <memory>
12
13namespace vitrio
14{
15
37class VITRIO_API counting_completion final
38 : public completion
39 , public completion_notifier
40{
41public:
51 explicit counting_completion(std::size_t count);
52
53 counting_completion(const counting_completion &other) = delete;
55
56 ~counting_completion() override;
57
59 operator=(const counting_completion &other) = delete;
61 operator=(counting_completion &&other) = delete;
62
63 void notify_done(std::exception_ptr error = nullptr) override;
64
65 void wait() const override;
66
67 bool is_ready() const noexcept override;
68
69 void get() const override;
70
71private:
72 class implementation;
73 VITRIO_STD_MEMBER_INTERFACE
74 std::unique_ptr<implementation> m_implementation;
75};
76
77} // namespace vitrio
void get() const override
Wait, then rethrow the first exception recorded, if any.
void notify_done(std::exception_ptr error=nullptr) override
Report that one unit of work has finished.
void wait() const override
Block the calling thread until this is ready.
bool is_ready() const noexcept override
Whether the work behind this has finished.
counting_completion(std::size_t count)
Construct a completion for a known number of units of work.