# Crow: crow::detail::task_timer Class Reference

Loading...
Searching...
No Matches
crow::detail::task_timer Class Reference

A class for scheduling functions to be called after a specific amount of ticks. A tick is equal to 1 second. More...

`#include <task_timer.h>`

## Public Types

using | task_type = std::function< void()>
using | identifier_type = size_t

## Public Member Functions

| task_timer (asio::io_service &io_service)
void | cancel (identifier_type id)
identifier_type | schedule (const task_type &task)
| Schedule the given task to be executed after the default amount of ticks.
identifier_type | schedule (const task_type &task, std::uint8_t timeout)
| Schedule the given task to be executed after the given time.
void | set_default_timeout (std::uint8_t timeout)
| Set the default timeout for this task_timer instance. (Default: 5)
std::uint8_t | get_default_timeout () const
| Get the default timeout. (Default: 5)

## Detailed Description

A class for scheduling functions to be called after a specific amount of ticks. A tick is equal to 1 second.

## Member Function Documentation

## schedule() [1/2]

identifier_type crow::detail::task_timer::schedule | ( | const task_type & | task | ) |

inline

Schedule the given task to be executed after the default amount of ticks.

Returns
  identifier_type Used to cancel the thread. It is not bound to this task_timer instance and in some cases could lead to undefined behavior if used with other task_timer objects or after the task has been successfully executed.

## schedule() [2/2]

identifier_type crow::detail::task_timer::schedule | ( | const task_type & | task,
|  | std::uint8_t | timeout
| ) |  |

inline

Schedule the given task to be executed after the given time.

Parameters

  timeout | The amount of ticks (seconds) to wait before execution.

Returns
  identifier_type Used to cancel the thread. It is not bound to this task_timer instance and in some cases could lead to undefined behavior if used with other task_timer objects or after the task has been successfully executed.

## set_default_timeout()

void crow::detail::task_timer::set_default_timeout | ( | std::uint8_t | timeout | ) |

inline

Set the default timeout for this task_timer instance. (Default: 5)

Parameters

  timeout | The amount of ticks (seconds) to wait before execution.

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

- include/crow/task_timer.h