vitrio 0.3.1
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
vitrio::counting_notifier Class Referencefinal

A notifier that reports to another once a fixed number of units of work have all reported to it. More...

#include <vitrio/concurrency/counting_notifier.hpp>

Inheritance diagram for vitrio::counting_notifier:
Collaboration diagram for vitrio::counting_notifier:

Public Member Functions

 counting_notifier (std::size_t count, std::shared_ptr< completion_notifier > parent)
 Construct a notifier for a known number of units of work.
 counting_notifier (const counting_notifier &other)=delete
 counting_notifier (counting_notifier &&other)=delete
counting_notifier & operator= (const counting_notifier &other)=delete
counting_notifier & operator= (counting_notifier &&other)=delete
void notify_done (std::exception_ptr error=nullptr) override
 Report that one unit of work has finished.
Public Member Functions inherited from vitrio::completion_notifier
 completion_notifier (const completion_notifier &other)=default
 completion_notifier (completion_notifier &&other)=default
completion_notifier & operator= (const completion_notifier &other)=default
completion_notifier & operator= (completion_notifier &&other)=default

Detailed Description

A notifier that reports to another once a fixed number of units of work have all reported to it.

It makes several units of work one unit of the notifier it reports to: the reads of one file in a batch, for example, each reported here, become one report of the file to the batch. It reports once every unit has reported, whichever failed, and reports the first exception reported, if any; the rest are discarded.

Thread safety
notify_done may be called concurrently, from as many threads as the starting count.

Constructor & Destructor Documentation

◆ counting_notifier()

vitrio::counting_notifier::counting_notifier ( std::size_t count,
std::shared_ptr< completion_notifier > parent )

Construct a notifier for a known number of units of work.

A count of zero reports to parent at once, from this constructor, as a success.

Parameters
countHow many times notify_done is reported before this reports to parent.
parentWhere the outcome of them all is reported. Must not be null.
Exceptions
std::invalid_argumentIf parent is null.

Member Function Documentation

◆ notify_done()

void vitrio::counting_notifier::notify_done ( std::exception_ptr error = nullptr)
overridevirtual

Report that one unit of work has finished.

Called exactly once per unit of work this notifier stands for.

Parameters
errorThe exception the unit of work raised, or null if it succeeded.
Thread safety
May be called concurrently, from as many threads as there are units of work.

Implements vitrio::completion_notifier.


The documentation for this class was generated from the following file: