-
Notifications
You must be signed in to change notification settings - Fork 0
Runques
Runque represents queue of items ready to be served to consumers for processing. Order in which ready items are consumed can be configured by the user. Three options are available:
- FIFO - the first item made available gets served first
- LIFO - the last item made available gets served first
- Priority - available item with highest user-defined priority gets served first
frq::make_runque_t metafunction offers a way to configure desired runque:
template<typename Order,
typename Mtm,
typename Ty,
typename Alloc,
typename... Rest>
using make_runque_t = /* ... */;
-
Orderdefines in which order ready items are consumed. One of the following options are available:fifo_orderlifo_order-
priority_order.
-
Mtmdefines multithreading model. Onlycoro_thread_modelis implemented. -
Tyis type of items stored in runque -
Allocis obviously allocator used by queue itself -
Restcan be used for passing additional parameters to desired runque type. In case ofpriority_order, it definesLessThenoperation passed to underlying priority queue.
Ty parameter is not the same as user type on which forque operates. It is wrapping type that allows consumer to control item's lifetime. The type also provides a way to notify forque that item has been processed so it can ready next related item, if available.
Type returned by make_runque_t metafunction will satisfy runlike concept which is defined as:
template<typename Ty>
concept runlike = requires(Ty s) {
typename Ty::value_type;
requires runnable<typename Ty::value_type>;
typename Ty::get_type;
{ s.get() } ->std::same_as<typename Ty::get_type>;
{ s.put(std::declval<typename Ty::value_type&&>()) };
};
where:
-
value_type- is type of items stored in the queue which needs to satisfyrunnableconcept, -
get_type- is return type ofget()member function that yields next available item, -
get- is a function returning next available item and -
put- is function adding item to the queue
runnable concept is rather simple. It only requires non-throwing move constructor:
template<typename Ty>
concept runnable =
std::is_nothrow_move_constructible_v<Ty> && !std::is_reference_v<Ty>;
User's only responsibility is to configure desired runque type and to provide it to forque. User will not interact with runque directly.