The budding task dropper is a task dropper which implements the logic for its own reproduction so buds (children) are modified depending on the difference between last idle time length and current idle time length.
More...
|
| BuddingTaskDropper (int const maxTasks=32, int const delta1=8, int const initDelta1=8, int const delta2=1, char const lastSign=0) |
| Default constructor for the budding task dropper. More...
|
|
BudType | emptyClone () const |
| Do an empty clone of this budding task dropper. It is, an exact clone but with an empty tasks vector. More...
|
|
virtual BudType | reproduce (char const sign) |
| Do the budding reproduction of current task dropper. More...
|
|
virtual BudType | evolve (long &lastIdle, long const idle, long const idleTh=100000, long const idleEps=100000) |
| Create the bud of current budding task dropper according to the defined evolutive criteria. More...
|
|
virtual char | getLastSign () const |
| Obtain the last sign of the budding task dropper. More...
|
|
virtual int | getDelta1 () const |
| Obtain the \(\Delta_1\) of the budding task dropper. More...
|
|
virtual int | getInitDelta1 () const |
| Obtain the init value of \(Delta_1\) of the budding task dropper. More...
|
|
virtual int | getDelta2 () const |
| Obtain the \(\Delta_2\) of the budding task dropper. More...
|
|
| TaskDropper (size_t const maxTasks=32) |
| Default constructor for TaskDropper. More...
|
|
virtual bool | add (shared_ptr< TaskType > task) |
| Add a task to the TaskDropper. More...
|
|
virtual bool | add (shared_ptr< TaskType > task, TaskArgs ... args) |
| Like TaskDropper::add but for tasks with arguments. More...
|
|
virtual bool | add (ThreadPoolType &pool, shared_ptr< TaskType > task) |
| Like TaskDropper::add but running the drop method in parallel through a callback from given thread pool. More...
|
|
virtual char | tryAdd (ThreadPoolType &pool, shared_ptr< TaskType > task) |
| Like TaskDropper::add(ThreadPoolType &, shared_ptr<TaskType>) but supporting non-blocking calls. More...
|
|
virtual void | drop () |
| Drop all tasks, one after another. More...
|
|
virtual void | drop (TaskArgs ... args) |
| Drop all tasks with arguments, one after another. More...
|
|
virtual void | drop (ThreadPoolType &pool) |
| A callback for TaskDropper::drop but using a thread pool to be executed in parallel. More...
|
|
virtual bool | tryDrop (ThreadPoolType &pool) |
| Like drop(ThreadPoolType &) but supporting non blocking calls. More...
|
|
TaskDropper | emptyClone () const |
| Do an empty clone of this task dropper. It is, an exact clone but with an empty tasks vector. More...
|
|
virtual void | operator() () |
| Void functor operator calling drop method to be compatible with thread pools. More...
|
|
virtual void | operator() (TaskArgs ... args) |
| Functor operator with arguments calling drop method with arguments which can be used by thread pools. More...
|
|
virtual size_t | getMaxTasks () const |
| Get current maximum tasks limit. More...
|
|
virtual void | setMaxTasks (size_t const maxTasks) |
| Set new maximum tasks limit. More...
|
|
virtual shared_ptr< TaskType > | popTask () |
| Pop a task from vector of tasks. More...
|
|
template<typename BudType, typename TaskType, typename ThreadPoolType, typename ... TaskArgs>
class BuddingTaskDropper< BudType, TaskType, ThreadPoolType, TaskArgs >
The budding task dropper is a task dropper which implements the logic for its own reproduction so buds (children) are modified depending on the difference between last idle time length and current idle time length.
The responsibility of measuring idle time lengths lies outside this class scope. A budding task dropper implements the logic of how to work with idle times, but it does not provide a mechanism to do such measurements.
To understand how budding task dropper works, let \(\epsilon\) be the minimum magnitude of a measurement so any measurement \(<\epsilon\) will be discarded. Let \(\tau\) be the threshold defining the significance of a measurement and let \(\Delta_1\) and \(\Delta_2\) be the parameters defining the behavior of a budding task dropper. Notice the \(\Delta_1\) of the source budding task dropper (the first one, which has no father) will be noted as \(\Delta_0\). Also, let \(t_a\) be the last idle time length and \(t_b\) be the current idle time length. Thus, if \(B_a\) is the parent budding task dropper and \(B_b\) is the child budding task dropper, the last can be defined as:
\[ B_b \approx \left\{\begin{array}{lll} B_a &,& t_b < \tau \\ r\left(B_a, {\mathrm{sgn}(t_a-t_b)s}\right) &,& t_b \geq \tau \land \left\vert{t_a-t_b}\right\vert > \epsilon \\ r\left(B_a, s\right) &,& t_b \geq \tau \land \left\vert{t_a-t_b}\right\vert \leq \epsilon \\ \end{array}\right. \]
Where \(B_b \approx B_a\) means \(B_b\) is exactly equal to \(B_a\) except for the vector of tasks. On the other hand, let \(m\) be the chunk size (max tasks) and \(s\) be the sign of \(B_a\) so the reproduce function \(r\) can be defined as:
\[ r\left(B_a, s^{'}\right) = r\left(\left[\begin{array}{c} m \\ \Delta_1 \\ \Delta_2 \\ s \end{array}\right], s^{'}\right) = B_b = \left[\begin{array}{l} m^{'} \\ \Delta_1^{'} \\ \Delta_2^{'} \\ s^{'} \end{array}\right] = \left[\begin{array}{c} m + s^{'} \delta\left({\Delta_1}, s, s^{'}\right) \\ \delta\left({\Delta_1}, s, s^{'}\right) \\ \Delta_2, \\ s{'} \end{array}\right] \]
Finally, \(\delta(\Delta_1, s, s^{'})\) works as follows:
\[ \delta\left({\Delta_1, s, s^{'}}\right) = \left\{\begin{array}{lll} \Delta_1 + \Delta_2 &,& s=s^{'} \\ \Delta_0 &,& s \neq s^{'} \end{array}\right. \]
- Template Parameters
-
BudType | Type of bud. Classes extending budding task dropper should specify themselves as the bud type. |
- See also
- TaskDropper
-
BuddingTaskDropper::evolve
-
BuddingTaskDropper::reproduce