45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/*
|
|||
|
|
* SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0
|
||
|
|
|
||
|
|
* Copyright 2016-2023 Unisoc (Shanghai) Technologies Co., Ltd
|
||
|
|
|
||
|
|
* Licensed under the Unisoc General Software License, version 1.0 (the License);
|
||
|
|
* you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
||
|
|
|
||
|
|
* https://www.unisoc.com/en_us/license/UNISOC_GENERAL_LICENSE_V1.0-EN_US
|
||
|
|
|
||
|
|
* Software distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
|
* WITHOUT WARRANTIES OF ANY KIND, either express or implied.
|
||
|
|
* See the Unisoc General Software License, version 1.0 for more details.
|
||
|
|
*/
|
||
|
|
#include <cassert>
|
||
|
|
#include <errno.h>
|
||
|
|
#include <sys/poll.h>
|
||
|
|
#include <sys/time.h>
|
||
|
|
#include <dbus/dbus.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
#include "Debug.h"
|
||
|
|
#include "DefaultTimeout.h"
|
||
|
|
#include "EventLoop.h"
|
||
|
|
|
||
|
|
using namespace UDBus;
|
||
|
|
|
||
|
|
DefaultTimeout::DefaultTimeout(int interval, bool repeat, EventLoop* eventLoop)
|
||
|
|
: mInterval(interval), mRepeat(repeat), mExpiration(0), mData(0), mMainLoop(eventLoop), mEnabled(false)
|
||
|
|
{
|
||
|
|
double current_time = EventLoop::GetMonotonicTime();
|
||
|
|
mExpiration = current_time + interval;
|
||
|
|
}
|
||
|
|
void DefaultTimeout::UpdateExpiration(int interval)
|
||
|
|
{
|
||
|
|
double current_time = EventLoop::GetMonotonicTime();
|
||
|
|
mInterval = interval;
|
||
|
|
mExpiration = current_time + interval;
|
||
|
|
}
|
||
|
|
|
||
|
|
DefaultTimeout::~DefaultTimeout()
|
||
|
|
{
|
||
|
|
DEBUG("");
|
||
|
|
}
|