Passenger: Passenger::Timer Class Reference

# Passenger::Timer Class Reference

A Timer which one can use to check how much time has elapsed since the timer started. More...

`#include <Timer.h>`

List of all members.

## Public Member Functions
| Timer (bool startNow=true)
| Creates a new Timer object.
void | start ()
| Start the timer.
void | stop ()
| Stop the timer.
unsigned long long | elapsed () const
| Returns the amount of time that has elapsed since the timer was last started, in miliseconds.
void | wait (unsigned long long time) const
| Wait until time miliseconds have elapsed since the timer was last started.

## Detailed Description

A Timer which one can use to check how much time has elapsed since the timer started.

This timer support miliseconds-resolution, but the exact resolution depends on the OS and the hardware.

This class is thread-safe.

     Timer timer;
     sleep(10);
     timer.elapsed();   // => about 10000 (msec)

## Constructor & Destructor Documentation

Passenger::Timer::Timer | ( | bool | startNow = `true` | ) | `[inline]`

Creates a new Timer object.

Parameters:

  | startNow | Whether the timer should be started immediately.

## Member Function Documentation

unsigned long long Passenger::Timer::elapsed | ( |  | ) | const`[inline]`

Returns the amount of time that has elapsed since the timer was last started, in miliseconds.

If the timer is currently stopped, then 0 is returned.

void Passenger::Timer::start | ( |  | ) | `[inline]`

Start the timer.

If the timer was already started, then this will restart the timer.

void Passenger::Timer::stop | ( |  | ) | `[inline]`

Stop the timer.

If there's currently another thread waiting on the wait() call, then that wait() call will block indefinitely until you call start() and sufficient amount of time has elapsed.

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

- Timer.h