Template Class parametrized_command_queue
Defined in File command.h
Inheritance Relationships
Base Type
private liberate::concurrency::command::command_queue_base< queueT >
(Template Class command_queue_base)
Class Documentation
-
template<template<typename> typename queueT>
class parametrized_command_queue : private liberate::concurrency::command::command_queue_base<queueT> With the base in place, we can offer more convenient command queue functions.
Public Types
-
using base_type = command_queue_base<queueT>
Convenience alias for base queue type.
-
using notification_function = std::function<void(parametrized_command_queue&)>
A notification function can be invoked when there are items in the command queue.
Public Functions
-
inline parametrized_command_queue() = default
Constructors take zero, one or two notification functions. If two are given, the first is invoked in-line whenever a command is enqueued. The escond is given whenever a result is enqueued.
If only one is given, the function is invoked for commands and results.
If none is given, there is no notification of added content.
-
inline explicit parametrized_command_queue(notification_function general_notification)
Constructors take zero, one or two notification functions. If two are given, the first is invoked in-line whenever a command is enqueued. The escond is given whenever a result is enqueued.
If only one is given, the function is invoked for commands and results.
If none is given, there is no notification of added content.
- Parameters
general_notification – [in] A notification_function that is invoked both when commands or results are placed in the queue.
-
inline explicit parametrized_command_queue(notification_function command_notification, notification_function result_notification)
Constructors take zero, one or two notification functions. If two are given, the first is invoked in-line whenever a command is enqueued. The escond is given whenever a result is enqueued.
If only one is given, the function is invoked for commands and results.
If none is given, there is no notification of added content.
- Parameters
command_notification – [in] A notification_function that is invoked when commands are placed in the queue.
result_notification – [in] A notification_function that is invoked when results are placed in the queue.
-
virtual ~parametrized_command_queue() = default
Virtual destructor
-
template<typename commandT, typename ...argsT>
inline void enqueue_command(command_type type, argsT&&... args) Convenience variant of enqueue_command that creates the command context with create_context before enqueueing it.
-
inline void enqueue_command(command_ptr &&command)
Enqueue a command. This takes ownership of the
command
parameter.Invokes the command notification function.
- Parameters
command – [inout] A command such as created with e.g. create_context.
-
inline command_ptr dequeue_command()
Dequeue a command.
- Returns
A command_ptr, which may be
nullptr
if there is no command in the queue.
-
inline void put_results(command_ptr &&results)
Push results into the response queue. This also accepts a command_ptr, and also takes ownership, just like enqueue_command - but it is used for when command processing completed.
Invokes the result notification function.
- Parameters
results – [inout] A completed command (with results).
-
template<typename commandT, typename ...argsT>
inline void put_results(command_ptr &&results, argsT&&... args)
-
inline command_ptr get_completed()
Retrieve a completed command (with results), or
nullptr
if none is in the queue.- Returns
The command_ptr with results (or
nullptr
).
-
inline std::size_t commands() const
- Returns
the number of commands in queue.
-
inline std::size_t results() const
- Returns
the number of results in queue.
-
inline bool empty() const
- Returns
true if there are no commands or results in queue, false if either exist.
-
using base_type = command_queue_base<queueT>