Timer.cc revision a1bde736
1a1bde736SShuo Chen// excerpts from http://code.google.com/p/muduo/ 2a1bde736SShuo Chen// 3a1bde736SShuo Chen// Use of this source code is governed by a BSD-style license 4a1bde736SShuo Chen// that can be found in the License file. 5a1bde736SShuo Chen// 6a1bde736SShuo Chen// Author: Shuo Chen (chenshuo at chenshuo dot com) 7a1bde736SShuo Chen 8a1bde736SShuo Chen#include "Timer.h" 9a1bde736SShuo Chen 10a1bde736SShuo Chenusing namespace muduo; 11a1bde736SShuo Chen 12a1bde736SShuo ChenAtomicInt64 Timer::s_numCreated_; 13a1bde736SShuo Chen 14a1bde736SShuo Chenvoid Timer::restart(Timestamp now) 15a1bde736SShuo Chen{ 16a1bde736SShuo Chen if (repeat_) 17a1bde736SShuo Chen { 18a1bde736SShuo Chen expiration_ = addTime(now, interval_); 19a1bde736SShuo Chen } 20a1bde736SShuo Chen else 21a1bde736SShuo Chen { 22a1bde736SShuo Chen expiration_ = Timestamp::invalid(); 23a1bde736SShuo Chen } 24a1bde736SShuo Chen} 25