atscppapi
1.0.9
C++ wrapper for Apache Traffic Server API
Main Page
Classes
Files
File List
File Members
•
All
Classes
Files
Functions
Enumerations
Enumerator
Macros
src
include
atscppapi
AsyncTimer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013 LinkedIn Corp. All rights reserved.
3
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of the license at
5
* http://www.apache.org/licenses/LICENSE-2.0
6
*
7
* Unless required by applicable law or agreed to in writing, software distributed under the
8
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9
* either express or implied.
10
*
11
*/
12
13
/**
14
* @file AsyncTimer.h
15
* @author Brian Geffon
16
* @author Manjesh Nilange
17
*/
18
19
#pragma once
20
#ifndef ATSCPPAPI_ASYNCTIMER_H_
21
#define ATSCPPAPI_ASYNCTIMER_H_
22
23
#include <string>
24
#include <
atscppapi/shared_ptr.h
>
25
#include <
atscppapi/Async.h
>
26
#include <
atscppapi/Request.h
>
27
#include <
atscppapi/Response.h
>
28
29
namespace
atscppapi {
30
31
// forward declarations
32
class
AsyncTimerState;
33
34
/**
35
* @brief This class provides an implementation of AsyncProvider that
36
* acts as a timer. It sends events at the set frequency. Calling the
37
* destructor will stop the events. A one-off timer just sends one
38
* event. Calling the destructor before this event will cancel the timer.
39
*
40
* For either type, user must delete the timer.
41
*
42
* See example async_timer for sample usage.
43
*/
44
class
AsyncTimer
:
public
AsyncProvider
{
45
public
:
46
47
enum
Type { TYPE_ONE_OFF = 0, TYPE_PERIODIC };
48
49
/**
50
* Constructor.
51
*
52
* @param type A one-off timer fires only once and a periodic timer fires periodically.
53
* @param period_in_ms The receiver will receive an event every this many milliseconds.
54
* @param initial_period_in_ms The first event will arrive after this many milliseconds. Subsequent
55
* events will have "regular" cadence. This is useful if the timer is
56
* set for a long period of time (1hr etc.), but an initial event is
57
* required. Value of 0 (default) indicates no initial event is desired.
58
*/
59
AsyncTimer
(Type type,
int
period_in_ms,
int
initial_period_in_ms = 0);
60
61
~
AsyncTimer
();
62
63
/**
64
* Starts the timer.
65
*/
66
void
run
(shared_ptr<AsyncDispatchControllerBase> dispatch_controller);
67
68
private
:
69
AsyncTimerState
*state_;
70
};
71
72
}
/* atscppapi */
73
74
#endif
/* ATSCPPAPI_ASYNCTIMER_H_ */
Generated on Mon Oct 14 2013 11:39:29 for atscppapi by
1.8.3.1