当前位置: 首页 > news >正文

怎么做qq二维码网站盐城seo网站优化软件

怎么做qq二维码网站,盐城seo网站优化软件,淘宝客网站如何做推广,手机wap网站开发简介 Timer 类是 muduo 网络库中的一个定时器类,用于在指定的时间间隔后执行某个任务。 Timer 类提供了一系列的方法来创建、启动、停止和删除定时器,以及设置定时器的时间间隔和回调函数等。 在 muduo 网络库中,Timer 类被广泛应用于各种…

简介

Timer 类是 muduo 网络库中的一个定时器类,用于在指定的时间间隔后执行某个任务。

Timer 类提供了一系列的方法来创建、启动、停止和删除定时器,以及设置定时器的时间间隔和回调函数等。

在 muduo 网络库中,Timer 类被广泛应用于各种网络任务中,例如定期发送心跳包、更新缓存、清理资源等。通过使用 Timer 类,我们可以方便地实现定时任务,提高网络应用程序的可靠性和稳定性。

以下是 muduo 网络库中 Timer 类的主要方法和功能:

  1. Timer::start():启动定时器,在指定的时间间隔后调用回调函数。
  2. Timer::stop():停止定时器,不再执行定时任务。
  3. Timer::restart():重新启动定时器,重新开始执行定时任务。
  4. Timer::reset():重新设置定时器的时间间隔和回调函数。
  5. Timer::getExpiryTime():获取定时器的到期时间。

通过使用 Timer 类,我们可以方便地实现各种定时任务,提高网络应用程序的可靠性和稳定性。同时,Timer 类也提供了一些高级功能,例如可以设置多个定时器,以及在多个线程中安全地使用定时器等。

源码剖析

Timer.h

// Copyright 2010, Shuo Chen.  All rights reserved.
// http://code.google.com/p/muduo/
//
// Use of this source code is governed by a BSD-style license
// that can be found in the License file.// Author: Shuo Chen (chenshuo at chenshuo dot com)
//
// This is an internal header file, you should not include this.#ifndef MUDUO_NET_TIMER_H
#define MUDUO_NET_TIMER_H#include "muduo/base/Atomic.h"
#include "muduo/base/Timestamp.h"
#include "muduo/net/Callbacks.h"namespace muduo
{
namespace net
{///
/// Internal class for timer event.
///
class Timer : noncopyable
{public:Timer(TimerCallback cb, Timestamp when, double interval): callback_(std::move(cb)),expiration_(when),interval_(interval),repeat_(interval > 0.0),sequence_(s_numCreated_.incrementAndGet()){ }//调用回调函数void run() const{callback_();}Timestamp expiration() const  { return expiration_; }bool repeat() const { return repeat_; }int64_t sequence() const { return sequence_; }//刷新时间戳void restart(Timestamp now);static int64_t numCreated() { return s_numCreated_.get(); }private://超时回调函数const TimerCallback callback_;//时间戳Timestamp expiration_;//时间间隔const double interval_;//是否重复const bool repeat_;//顺序编号const int64_t sequence_;//生成顺序的编号static AtomicInt64 s_numCreated_;
};}  // namespace net
}  // namespace muduo#endif  // MUDUO_NET_TIMER_H

Timer.cc

// Copyright 2010, Shuo Chen.  All rights reserved.
// http://code.google.com/p/muduo/
//
// Use of this source code is governed by a BSD-style license
// that can be found in the License file.// Author: Shuo Chen (chenshuo at chenshuo dot com)#include "muduo/net/Timer.h"using namespace muduo;
using namespace muduo::net;AtomicInt64 Timer::s_numCreated_;void Timer::restart(Timestamp now)
{if (repeat_){expiration_ = addTime(now, interval_);}else{expiration_ = Timestamp::invalid();}
}
http://www.hkea.cn/news/979677/

相关文章:

  • 网站开发需要什么软件百度怎样发布作品
  • 专门做宠物食品的网站市场调研怎么做
  • 兰州网站建设q.479185700棒成年s8视频加密线路
  • 付费网站推广seo关键词排名优化怎么收费
  • 网站由那些组成google网页搜索
  • 对一个网站做性能测试谷歌paypal官网入口
  • 北京住房投资建设中心网站首页快速排名怎么做
  • 中国网站制作 第一个佛山网站优化
  • thinkphp做的教育网站微商引流推广
  • 做特卖网站手机版电商最好卖的十大产品
  • 怎样做网站平叿trinseo公司
  • 北京大兴最专业的网站建设公司如何推广一个项目
  • 网页设计最牛的网站建设宁波网站优化公司哪家好
  • 建设通查询如何做网站推广及优化
  • 城乡建设网站首页百度seo收录软件
  • 永久免费建个人网站培训网站建设
  • 如何使用jq做弹幕网站好用的磁力搜索引擎
  • 南充营销型网站建设高端品牌网站建设
  • 制作小程序和网站的公司搜狗收录提交入口网址
  • 手机站电影基础建站如何提升和优化
  • 江苏 网站备案百度贴吧官网app下载
  • 网站制作三站湖南网站seo公司
  • 简单做任务赚钱网站企业管理培训课程报名
  • 零点研究咨询集团官方网站建设相似图片在线查找
  • 网站开发需要什么软件关键词app
  • 360全景网站建设做了5天游戏推广被抓了
  • 政府网站建设经验典型材料河源今日头条新闻最新
  • 为什么要进行网站备案佛山市人民政府门户网站
  • 摄影网站开发背景百度app交易平台
  • 吉林网站建设石家庄百度快照优化排名