mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLUTTER_FML_PLATFORM_LINUX_TIMER_FD_H_
|
|
#define FLUTTER_FML_PLATFORM_LINUX_TIMER_FD_H_
|
|
|
|
#include "lib/fxl/time/time_point.h"
|
|
|
|
// clang-format off
|
|
#if __has_include(<sys/timerfd.h>)
|
|
// clang-format on
|
|
|
|
#include <sys/timerfd.h>
|
|
|
|
#define FML_TIMERFD_AVAILABLE 1
|
|
|
|
#else // __has_include(<sys/timerfd.h>)
|
|
|
|
#define FML_TIMERFD_AVAILABLE 0
|
|
|
|
#include <sys/types.h>
|
|
// Must come after sys/types
|
|
#include <linux/time.h>
|
|
|
|
#define TFD_TIMER_ABSTIME (1 << 0)
|
|
#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
|
|
|
|
#define TFD_CLOEXEC O_CLOEXEC
|
|
#define TFD_NONBLOCK O_NONBLOCK
|
|
|
|
int timerfd_create(int clockid, int flags);
|
|
|
|
int timerfd_settime(int ufc,
|
|
int flags,
|
|
const struct itimerspec* utmr,
|
|
struct itimerspec* otmr);
|
|
|
|
#endif // __has_include(<sys/timerfd.h>)
|
|
|
|
namespace fml {
|
|
|
|
/// Rearms the timer to expire at the given time point.
|
|
bool TimerRearm(int fd, fxl::TimePoint time_point);
|
|
|
|
/// Drains the timer FD and retuns true if it has expired. This may be false in
|
|
/// case the timer read is non-blocking and this routine was called before the
|
|
/// timer expiry.
|
|
bool TimerDrain(int fd);
|
|
|
|
} // namespace fml
|
|
|
|
#endif // FLUTTER_FML_PLATFORM_LINUX_TIMER_FD_H_
|