| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Private Attributes | List of all members
boost::threadpool::looped_task_func Class Reference

Looped task function object. More...

`#include <src/threadpool/boost/threadpool/task_adaptors.hpp>`

## Public Types
typedef void | result_type
| Indicates the functor's result type. More...

## Public Member Functions
| looped_task_func (function0< bool > const &function, unsigned int const interval=0)
| Constructor. More...
void | operator() (void) const
| Executes the task function. More...

## Private Attributes
function0< bool > | m_function
| The task's function. More...
unsigned int | m_break_s
| Duration of breaks in seconds. More...
unsigned int | m_break_ns
| Duration of breaks in nano seconds. More...

## Detailed Description

Looped task function object.

This function object wraps a boolean thread function object. The wrapped task function is invoked by calling the operator () and it is executed in regular time intervals until false is returned. The interval length may be zero. Please note that a pool's thread is engaged as long as the task is looped.

Definition at line 107 of file task_adaptors.hpp.

## Member Typedef Documentation

typedef void boost::threadpool::looped_task_func::result_type

Indicates the functor's result type.

Definition at line 118 of file task_adaptors.hpp.

## Constructor & Destructor Documentation

boost::threadpool::looped_task_func::looped_task_func | ( | function0< bool > const & | function,
|  | unsigned int const | interval = `0`
| ) |  |
| inline

Constructor.

Parameters

  function | The task's function object which is looped until false is returned.
  interval | The minimum break time in milli seconds before the first execution of the task function and between the following ones.

Definition at line 125 of file task_adaptors.hpp.

126 : m_function(function)
127 #if BOOST_VERSION >= 15000
128 , m_break(interval)
129 #endif
130 {
131 #if BOOST_VERSION < 15000
132 m_break_s = interval / 1000;
133 m_break_ns = (interval - m_break_s * 1000) * 1000 * 1000;
134 #endif
135 }
boost::threadpool::looped_task_func::m_function
function0< bool > m_function
The task&#39;s function.
Definition: task_adaptors.hpp:110
boost::threadpool::looped_task_func::m_break_ns
unsigned int m_break_ns
Duration of breaks in nano seconds.
Definition: task_adaptors.hpp:115
boost::threadpool::looped_task_func::m_break_s
unsigned int m_break_s
Duration of breaks in seconds.
Definition: task_adaptors.hpp:114

## Member Function Documentation

void boost::threadpool::looped_task_func::operator() | ( | void |  | ) | const
| inline

Executes the task function.

Definition at line 139 of file task_adaptors.hpp.

140 {
141 if(m_function)
142 {
143 #if BOOST_VERSION >= 15000
144 if(m_break > boost::chrono::milliseconds(0))
145 boost::this_thread::sleep_for(m_break);
146 #else
147 if(m_break_s > 0 || m_break_ns > 0)
148 {
149 // Sleep some time before first execution
150 xtime xt;
151 xtime_get(&xt, TIME_UTC);
152 xt.nsec += m_break_ns;
153 xt.sec += m_break_s;
154 thread::sleep(xt);
155 }
156 #endif
157 while(m_function())
158 {
159 #if BOOST_VERSION >= 15000
160 if(m_break > boost::chrono::milliseconds(0))
161 boost::this_thread::sleep_for(m_break);
162 #else
163 if(m_break_s > 0 || m_break_ns > 0)
164 {
165 xtime xt;
166 xtime_get(&xt, TIME_UTC);
167 xt.nsec += m_break_ns;
168 xt.sec += m_break_s;
169 thread::sleep(xt);
170 }
171 #endif
172 else
173 {
174 thread::yield(); // Be fair to other threads
175 }
176 }
177 }
178 }
boost::threadpool::looped_task_func::m_function
function0< bool > m_function
The task&#39;s function.
Definition: task_adaptors.hpp:110
boost::threadpool::looped_task_func::m_break_ns
unsigned int m_break_ns
Duration of breaks in nano seconds.
Definition: task_adaptors.hpp:115
boost::threadpool::looped_task_func::m_break_s
unsigned int m_break_s
Duration of breaks in seconds.
Definition: task_adaptors.hpp:114

## Member Data Documentation

unsigned int boost::threadpool::looped_task_func::m_break_ns
| private

Duration of breaks in nano seconds.

Definition at line 115 of file task_adaptors.hpp.

unsigned int boost::threadpool::looped_task_func::m_break_s
| private

Duration of breaks in seconds.

Definition at line 114 of file task_adaptors.hpp.

function0<bool> boost::threadpool::looped_task_func::m_function
| private

The task's function.

Definition at line 110 of file task_adaptors.hpp.

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

- GaudiMTTools/src/threadpool/boost/threadpool/task_adaptors.hpp