Timer.cc revision 354280cf
1354280cfSShuo Chen// excerpts from http://code.google.com/p/muduo/ 2354280cfSShuo Chen// 3354280cfSShuo Chen// Use of this source code is governed by a BSD-style license 4354280cfSShuo Chen// that can be found in the License file. 5354280cfSShuo Chen// 6354280cfSShuo Chen// Author: Shuo Chen (chenshuo at chenshuo dot com) 7354280cfSShuo Chen 8354280cfSShuo Chen#include "Timer.h" 9354280cfSShuo Chen 10354280cfSShuo Chenusing namespace muduo; 11354280cfSShuo Chen 12354280cfSShuo ChenAtomicInt64 Timer::s_numCreated_; 13354280cfSShuo Chen 14354280cfSShuo Chenvoid Timer::restart(Timestamp now) 15354280cfSShuo Chen{ 16354280cfSShuo Chen if (repeat_) 17354280cfSShuo Chen { 18354280cfSShuo Chen expiration_ = addTime(now, interval_); 19354280cfSShuo Chen } 20354280cfSShuo Chen else 21354280cfSShuo Chen { 22354280cfSShuo Chen expiration_ = Timestamp::invalid(); 23354280cfSShuo Chen } 24354280cfSShuo Chen} 25