代码拉取完成,页面将自动刷新
#pragma once
#include "TimeNode.h"
#include <unordered_map>
#include <vector>
#include <unistd.h>
#include <pthread.h>
#include <iostream>
#define IS_LESS_STAMP(i,j) (m_container[(i)]->timestamp<m_container[(j)]->timestamp)
#define C_SIZE (m_container.size())
//precise to second
class HeapTimer
{
public:
enum TimerManagerState
{
TIME_MANAGER_START,
TIME_MANAGER_STOP
};
public:
~HeapTimer();
//this example prove only one timer
static HeapTimer* instance();
int addTimer(TimeNode* newnode) ;
void deleteTimer(int id) ;
void clear();
void start();
void stop();
private:
static void* process(void* arg);
explicit HeapTimer(/* args */);
private:
//try minheap
void sinkdown(int index);//for delete
void popup(int index);//for insert
void insertTimeNode(TimeNode* newnode);
void deleteTimeNode(TimeNode* node);
void swapTimeNode(int i,int j);
TimeNode* front();
private:
//vector is more comfortable
std::vector<TimeNode*> m_container;
//log(1) to find node id->TimeNode
std::unordered_map<int,TimeNode*> m_node_location;
static std::atomic<HeapTimer*> smp_heaptimer;
static std::atomic<TimerManagerState> m_status;//pthread is runing or not
static pthread_mutex_t sm_mutex;
pthread_t m_pid;
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。