virtual int timer_timeout(const ZCE_Time_Value &now_timenow_time,
                               const void *act)
    {
        char time_str[128];
        int timer_action = *(int *)act;
        std::cout << now_timenow_time.timestamp(time_str, 128) << " " << "Timer action =" << timer_action << std::endl;
        ZCE_Timer_Queue_Base::instance()->cancel_timer(this);

        ZCE_Time_Value delay_time(1, 0);
        ZCE_Time_Value interval_time(0, 0);

        int time_id = ZCE_Timer_Queue_Base::instance()->schedule_timer(this,
            &TEST_TIMER_ACT[timer_action-1],
            delay_time,
            interval_time);
        std::cout << now_timenow_time.timestamp(time_str, 128) << " " << "Timer id =" << time_id << std::endl;

        return 0;
    }
int ZCE_Conf_PropertyTree::path_get_leaf(const std::string &path_str,
        const std::string &key_str,
        ZCE_Time_Value &val) const
{
    std::string value_str;
    int ret = path_get_leaf<std::string>(path_str, key_str, value_str);

    if (0 != ret)
    {
        return ret;
    }
    val.from_string(value_str.c_str(), false, ZCE_LIB::TIME_STRFMT_US_SEC);
    return 0;
}
Esempio n. 3
0
// 检查监控是否超时
void Comm_Timer_Handler::check_monitor(const ZCE_Time_Value &now_time)
{
    time_t now_sec = now_time.sec();

    // 检查是否在同一个周期内
    if (now_sec / FIVE_MINUTE_SECONDS != last_check_ / FIVE_MINUTE_SECONDS)
    {
        // 添加进程存活监控
        report_status();
        stat_monitor_->check_overtime(now_sec);

        if (now_sec - last_check_ > FIVE_MINUTE_SECONDS)
        {
            ZLOG_ERROR("check monitor more than five minutes:real_second=%d %d",
                       now_sec - last_check_, now_sec % FIVE_MINUTE_SECONDS);
        }

        // 这里是为了保证每次检查在5分钟整
        last_check_ = now_sec - (now_sec % FIVE_MINUTE_SECONDS);
    }
}
Esempio n. 4
0
// 检查监控是否超时
void Server_Timer_Base::check_monitor(const ZCE_Time_Value &now_time)
{
    time_t now_sec = now_time.sec();

    // 检查是否在同一个周期内
    if (now_sec / ZCE_LIB::FIVE_MINUTE_SECONDS != last_check_ / ZCE_LIB::FIVE_MINUTE_SECONDS)
    {
        // 添加进程存活监控
        report_status();
        stat_monitor_->check_overtime(now_sec);

        if (now_sec - last_check_ > ZCE_LIB::FIVE_MINUTE_SECONDS)
        {
            ZCE_LOG(RS_ERROR, "check monitor more than five minutes:real_second=%d %d",
                    now_sec - last_check_, now_sec % ZCE_LIB::FIVE_MINUTE_SECONDS);
        }

        // 这里是为了保证每次检查在5分钟整
        last_check_ = now_sec - (now_sec % ZCE_LIB::FIVE_MINUTE_SECONDS);
    }
}
Esempio n. 5
0
ZCE_Time_Value str_to_value(const char *str)
{
    ZCE_Time_Value val;
    val.from_string(str, false, ZCE_LIB::TIME_STRFMT_US_SEC);
    return val;
}