当前位置: 技术问答>linux和unix
定时器问题,简单但高分!
来源: 互联网 发布时间:2015-06-07
本文导语: 定义 class A { private: int m_int; public: A(); ~A(); void abc(int signal); void efg(); } 实现:构造函数、析构函数略 void A::abc(int signal) { //错误2 m_int = 123;...
定义
class A
{
private:
int m_int;
public:
A();
~A();
void abc(int signal);
void efg();
}
实现:构造函数、析构函数略
void A::abc(int signal)
{ //错误2
m_int = 123;
}
void A::efg()
{
struct itimerval sTimeOld,sTimeNew;
sTimeNew.it_interval.tv_usec = 0;
sTimeNew.it_interval.tv_sec = T3;
sTimeNew.it_value.tv_usec = 0;
sTimeNew.it_value.tv_sec = T3;
signal(SIGALRM,abc); //错误1
if (setitimer(ITIMER_REAL,&sTimeNew,&sTimeOld)
class A
{
private:
int m_int;
public:
A();
~A();
void abc(int signal);
void efg();
}
实现:构造函数、析构函数略
void A::abc(int signal)
{ //错误2
m_int = 123;
}
void A::efg()
{
struct itimerval sTimeOld,sTimeNew;
sTimeNew.it_interval.tv_usec = 0;
sTimeNew.it_interval.tv_sec = T3;
sTimeNew.it_value.tv_usec = 0;
sTimeNew.it_value.tv_sec = T3;
signal(SIGALRM,abc); //错误1
if (setitimer(ITIMER_REAL,&sTimeNew,&sTimeOld)