Seregon/ShadPKG

A tool for deriving PKG packet encryption keys for ps4 written in c++

C++/47.3 KB/No license
common/thread.h
ShadPKG / common / thread.h
1// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project
2// SPDX-FileCopyrightText: 2014 Citra Emulator Project
3// SPDX-License-Identifier: GPL-2.0-or-later
4 
5#pragma once
6 
7#include <chrono>
8#include "common/shadpkg_types.h"
9 
10namespace Common {
11 
12enum class ThreadPriority : u32 {
13 Low = 0,
14 Normal = 1,
15 High = 2,
16 VeryHigh = 3,
17 Critical = 4,
18};
19 
20void SetCurrentThreadRealtime(std::chrono::nanoseconds period_ns);
21 
22void SetCurrentThreadPriority(ThreadPriority new_priority);
23 
24void SetCurrentThreadName(const char* name);
25 
26void SetThreadName(void* thread, const char* name);
27 
28class AccurateTimer {
29 std::chrono::nanoseconds target_interval{};
30 std::chrono::nanoseconds total_wait{};
31 
32 std::chrono::high_resolution_clock::time_point start_time;
33 
34public:
35 explicit AccurateTimer(std::chrono::nanoseconds target_interval);
36 
37 void Start();
38 
39 void End();
40 
41 std::chrono::nanoseconds GetTotalWait() const {
42 return total_wait;
43 }
44};
45 
46} // namespace Common
47