v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
platform-win32.h
Go to the documentation of this file.
1// Copyright 2023 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_BASE_PLATFORM_PLATFORM_WIN32_H_
6#define V8_BASE_PLATFORM_PLATFORM_WIN32_H_
7
9
10namespace v8 {
11namespace base {
12
13// A timer which allows more precise sleep intervals. Sleeping on Windows is
14// generally limited by the granularity of the system timer (64 Hz by default),
15// but on Windows 10 version 1803 and newer, this class allows much shorter
16// sleeps including sub-millisecond intervals.
18 public:
21
22 // Moving is supported but copying is not, because this class owns a
23 // platform handle.
24 PreciseSleepTimer(const PreciseSleepTimer& other) = delete;
28
29 // Attempts to initialize this timer. Precise timers are only available on
30 // Windows 10 version 1803 and later. To check whether initialization worked,
31 // use IsInitialized.
32 void TryInit();
33
34 bool IsInitialized() const;
35
36 // Sleeps for a specified time interval. This function requires that the timer
37 // has been initialized, as can be checked with IsInitialized. A single
38 // PreciseSleepTimer instance must not be used simultaneously on multiple
39 // threads.
40 void Sleep(TimeDelta interval) const;
41
42 private:
43 void Close();
45};
46
47} // namespace base
48} // namespace v8
49
50#endif // V8_BASE_PLATFORM_PLATFORM_WIN32_H_
#define V8_BASE_EXPORT
Definition base-export.h:26
PreciseSleepTimer & operator=(const PreciseSleepTimer &other)=delete
PreciseSleepTimer(const PreciseSleepTimer &other)=delete
#define V8_NOEXCEPT
void * HANDLE