TwiceAsNice  2019-02-18
Public Types | Public Member Functions | Private Attributes | List of all members
Nice::DispatcherSchedulerPrio< Task > Class Template Reference

SchedulingPolicy which implements prioritized ordering. More...

#include <DispatcherScheduler.hh>

Collaboration diagram for Nice::DispatcherSchedulerPrio< Task >:
Collaboration graph

Public Types

typedef Task TaskType
 Indicates the scheduler's task type. More...
 
typedef Task TaskType
 Indicates the scheduler's task type. More...
 

Public Member Functions

bool push (TaskType const &task)
 
bool pop (TaskType &_task)
 
size_t size () const
 
bool empty () const
 
void clear ()
 
bool push (TaskType const &task)
 
bool pop (TaskType &_task)
 
size_t size () const
 
bool empty () const
 
void clear ()
 

Private Attributes

std::priority_queue< TaskTypem_container
 Internal task container. More...
 
Nice::Mutex m_mutex
 

Detailed Description

template<typename Task>
class Nice::DispatcherSchedulerPrio< Task >

SchedulingPolicy which implements prioritized ordering.

This container implements a scheduling policy based on task priorities. The task with highest priority will be the first to be removed. It must be possible to compare two tasks using operator<.

Parameters
TaskA function object which implements the operator() and operator<. operator< must be a partial ordering.
See also
prio_thread_func

Member Typedef Documentation

◆ TaskType [1/2]

template<typename Task >
typedef Task Nice::DispatcherSchedulerPrio< Task >::TaskType

Indicates the scheduler's task type.

◆ TaskType [2/2]

template<typename Task >
typedef Task Nice::DispatcherSchedulerPrio< Task >::TaskType

Indicates the scheduler's task type.

Member Function Documentation

◆ clear() [1/2]

template<typename Task >
void Nice::DispatcherSchedulerPrio< Task >::clear ( )
inline

Removes all tasks from the scheduler.

◆ clear() [2/2]

template<typename Task >
void Nice::DispatcherSchedulerPrio< Task >::clear ( void  )
inline

Removes all tasks from the scheduler.

◆ empty() [1/2]

template<typename Task >
bool Nice::DispatcherSchedulerPrio< Task >::empty ( void  ) const
inline

Checks if the scheduler is empty.

Returns
true if the scheduler contains no tasks, false otherwise.
Remarks
Is more efficient than size() == 0.

◆ empty() [2/2]

template<typename Task >
bool Nice::DispatcherSchedulerPrio< Task >::empty ( ) const
inline

Checks if the scheduler is empty.

Returns
true if the scheduler contains no tasks, false otherwise.
Remarks
Is more efficient than size() == 0.

◆ pop() [1/2]

template<typename Task >
bool Nice::DispatcherSchedulerPrio< Task >::pop ( TaskType _task)
inline

Gets the task which should be executed next and remove it.

Returns
The task object to be executed.

◆ pop() [2/2]

template<typename Task >
bool Nice::DispatcherSchedulerPrio< Task >::pop ( TaskType _task)
inline

Gets the task which should be executed next and remove it.

Returns
The task object to be executed.

◆ push() [1/2]

template<typename Task >
bool Nice::DispatcherSchedulerPrio< Task >::push ( TaskType const task)
inline

Adds a new task to the scheduler.

Parameters
taskThe task object.
Returns
true, if the task could be scheduled and false otherwise.

◆ push() [2/2]

template<typename Task >
bool Nice::DispatcherSchedulerPrio< Task >::push ( TaskType const task)
inline

Adds a new task to the scheduler.

Parameters
taskThe task object.
Returns
true, if the task could be scheduled and false otherwise.

◆ size() [1/2]

template<typename Task >
size_t Nice::DispatcherSchedulerPrio< Task >::size ( ) const
inline

Gets the current number of tasks in the scheduler.

Returns
The number of tasks.
Remarks
Prefer empty() to size() == 0 to check if the scheduler is empty.

◆ size() [2/2]

template<typename Task >
size_t Nice::DispatcherSchedulerPrio< Task >::size ( void  ) const
inline

Gets the current number of tasks in the scheduler.

Returns
The number of tasks.
Remarks
Prefer empty() to size() == 0 to check if the scheduler is empty.

Member Data Documentation

◆ m_container

template<typename Task >
std::priority_queue< TaskType > Nice::DispatcherSchedulerPrio< Task >::m_container
private

Internal task container.

◆ m_mutex

template<typename Task >
Nice::Mutex Nice::DispatcherSchedulerPrio< Task >::m_mutex
private

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