Base type for a collection of delayed submissions. More...
#include <delayed_submission.h>
Public Member Functions | |
BaseDelayedSubmissionCollection (const std::string name, const bool enabled) | |
Constructor for a thread-safe delayed submission collection. More... | |
BaseDelayedSubmissionCollection (const BaseDelayedSubmissionCollection &)=delete | |
BaseDelayedSubmissionCollection & | operator= (BaseDelayedSubmissionCollection const &)=delete |
BaseDelayedSubmissionCollection (BaseDelayedSubmissionCollection &&o)=delete | |
BaseDelayedSubmissionCollection & | operator= (BaseDelayedSubmissionCollection &&o)=delete |
virtual void | schedule (T item) |
Register a callable or complex-type for delayed submission. More... | |
void | process () |
Process all pending callbacks. More... | |
Protected Member Functions | |
virtual void | scheduleLog (T item)=0 |
Log message during schedule() . More... | |
virtual void | processItem (T item)=0 |
Process a single item during process() . More... | |
Protected Attributes | |
std::string | _name {"undefined"} |
The human-readable name of the collection, used for logging. | |
bool | _enabled {true} |
Whether the resource required to process the collection is enabled. | |
std::vector< T > | _collection {} |
The collection. | |
std::mutex | _mutex {} |
Mutex to provide access to _collection . | |
Base type for a collection of delayed submissions.
Base type for a collection of delayed submission. Delayed submissions may have different purposes and this class encapsulates generic data for all derived types.
|
inlineexplicit |
Constructor for a thread-safe delayed submission collection.
Construct a thread-safe delayed submission collection. A delayed submission collection provides two operations: schedule and process. The schedule()
method will push an operation into the collection, whereas the process()
will invoke all callbacks that were previously pushed into the collection and clear the collection.
[in] | name | human-readable name of the collection, used for logging. |
[in] | enabled | whether the resource is enabled, if false an exception is raised when attempting to schedule a callable. Disabled instances of this class should only be used to provide a consistent interface among implementations. |
|
inline |
Process all pending callbacks.
Process all pending generic. Generic callbacks are deemed completed when their execution completes.
|
protectedpure virtual |
Process a single item during process()
.
Method called by process()
to process a single item of the collection.
[in] | item | the callback that was passed as argument to schedule() when the first registered. |
Implemented in ucxx::RequestDelayedSubmissionCollection, and ucxx::GenericDelayedSubmissionCollection.
|
inlinevirtual |
Register a callable or complex-type for delayed submission.
Register a simple callback, or complex-type with a callback (requires specialization), for delayed submission that will be executed when the request is in fact submitted when process()
is called.
Raise an exception if false
was specified as the enabled
argument to the constructor.
std::runtime_error | if _enabled is false . |
[in] | item | the callback that will be executed by process() when the operation is submitted. |
|
protectedpure virtual |
Log message during schedule()
.
Log a specialized message while schedule()
is being executed.
[in] | item | the callback that was passed as argument to schedule() . |
Implemented in ucxx::RequestDelayedSubmissionCollection, and ucxx::GenericDelayedSubmissionCollection.