forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add timer for batching reports. (envoyproxy#73)
* Add periodic timer. * change timer class. * rename Reset to Start.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* Copyright 2017 Istio Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef MIXERCLIENT_TIMER_H | ||
#define MIXERCLIENT_TIMER_H | ||
|
||
#include <memory> | ||
|
||
namespace istio { | ||
namespace mixer_client { | ||
|
||
// Represent a timer created by caller's environment. | ||
class Timer { | ||
public: | ||
// Delete the timer, stopping it first if needed. | ||
virtual ~Timer() {} | ||
|
||
// Stop a pending timeout without destroying the underlying timer. | ||
virtual void Stop() = 0; | ||
|
||
// Start a pending timeout. If a timeout is already pending, | ||
// it will be reset to the new timeout. | ||
virtual void Start(int interval_ms) = 0; | ||
}; | ||
|
||
// Defines a function to create a timer calling the function | ||
// with desired interval. The returned object can be used to stop | ||
// the timer. | ||
using TimerCreateFunc = | ||
std::function<std::unique_ptr<Timer>(std::function<void()> timer_func)>; | ||
|
||
} // namespace mixer_client | ||
} // namespace istio | ||
|
||
#endif // MIXERCLIENT_TIMER_H |