Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
Threading.h
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#ifndef THREADING_H
7
#define THREADING_H
8
9
#include <atomic>
10
#include <assert.h>
11
#include <cstdint>
12
#include <thread>
13
14
namespace
Skyfire
15
{
16
17
class
Runnable
18
{
19
public
:
20
Runnable
() :
m_refs
(0) { }
21
virtual
~Runnable
() { }
22
virtual
void
run
() = 0;
23
24
void
incReference
() { ++
m_refs
; }
25
void
decReference
()
26
{
27
if
(!--
m_refs
)
28
delete
this
;
29
}
30
private
:
31
std::atomic<long>
m_refs
;
32
};
33
34
enum
Priority
35
{
36
Idle
,
37
Lowest
,
38
Low
,
39
Normal
,
40
High
,
41
Highest
,
42
Realtime
43
};
44
45
#define MAXPRIORITYNUM (Realtime + 1)
46
47
class
ThreadPriority
48
{
49
public
:
50
ThreadPriority
();
51
int
getPriority
(
Priority
p)
const
;
52
53
private
:
54
int
m_priority
[
MAXPRIORITYNUM
];
55
};
56
57
class
Thread
58
{
59
public
:
60
Thread
();
61
explicit
Thread
(
Runnable
* instance);
62
~Thread
();
63
64
bool
start
();
65
bool
wait
();
66
void
destroy
();
67
68
void
suspend
();
69
void
resume
();
70
71
void
setPriority
(
Priority
type);
72
73
static
void
Sleep
(
unsigned
long
msecs);
74
static
uint64_t
currentId
();
75
static
std::thread::native_handle_type
currentHandle
();
76
static
Thread
*
current
();
77
78
private
:
79
Thread
(
const
Thread
&);
80
Thread
&
operator=
(
const
Thread
&);
81
82
static
void
ThreadTask
(
Runnable
* param);
83
84
uint64_t
m_iThreadId
;
85
std::thread
m_thread
;
86
Runnable
*
m_task
;
87
bool
m_started
;
88
};
89
90
}
91
92
#endif
MAXPRIORITYNUM
#define MAXPRIORITYNUM
Definition
Threading.h:45
Skyfire::Runnable
Definition
Threading.h:18
Skyfire::Runnable::incReference
void incReference()
Definition
Threading.h:24
Skyfire::Runnable::Runnable
Runnable()
Definition
Threading.h:20
Skyfire::Runnable::~Runnable
virtual ~Runnable()
Definition
Threading.h:21
Skyfire::Runnable::decReference
void decReference()
Definition
Threading.h:25
Skyfire::Runnable::m_refs
std::atomic< long > m_refs
Definition
Threading.h:31
Skyfire::Runnable::run
virtual void run()=0
Skyfire::Thread::current
static Thread * current()
Definition
Threading.cpp:124
Skyfire::Thread::operator=
Thread & operator=(const Thread &)
Skyfire::Thread::wait
bool wait()
Definition
Threading.cpp:75
Skyfire::Thread::~Thread
~Thread()
Definition
Threading.cpp:42
Skyfire::Thread::setPriority
void setPriority(Priority type)
Definition
Threading.cpp:136
Skyfire::Thread::destroy
void destroy()
Definition
Threading.cpp:88
Skyfire::Thread::m_thread
std::thread m_thread
Definition
Threading.h:85
Skyfire::Thread::ThreadTask
static void ThreadTask(Runnable *param)
Definition
Threading.cpp:105
Skyfire::Thread::Thread
Thread(const Thread &)
Skyfire::Thread::Thread
Thread()
Definition
Threading.cpp:30
Skyfire::Thread::suspend
void suspend()
Definition
Threading.cpp:97
Skyfire::Thread::currentHandle
static std::thread::native_handle_type currentHandle()
Definition
Threading.cpp:119
Skyfire::Thread::resume
void resume()
Definition
Threading.cpp:101
Skyfire::Thread::m_started
bool m_started
Definition
Threading.h:87
Skyfire::Thread::m_iThreadId
uint64_t m_iThreadId
Definition
Threading.h:84
Skyfire::Thread::start
bool start()
Definition
Threading.cpp:52
Skyfire::Thread::currentId
static uint64_t currentId()
Definition
Threading.cpp:114
Skyfire::Thread::m_task
Runnable * m_task
Definition
Threading.h:86
Skyfire::Thread::Sleep
static void Sleep(unsigned long msecs)
Definition
Threading.cpp:141
Skyfire::ThreadPriority::getPriority
int getPriority(Priority p) const
Definition
Threading.cpp:19
Skyfire::ThreadPriority::ThreadPriority
ThreadPriority()
Definition
Threading.cpp:13
Skyfire::ThreadPriority::m_priority
int m_priority[MAXPRIORITYNUM]
Definition
Threading.h:54
Skyfire
Definition
AuthPatchTransfer.h:12
Skyfire::Priority
Priority
Definition
Threading.h:35
Skyfire::Lowest
@ Lowest
Definition
Threading.h:37
Skyfire::High
@ High
Definition
Threading.h:40
Skyfire::Highest
@ Highest
Definition
Threading.h:41
Skyfire::Low
@ Low
Definition
Threading.h:38
Skyfire::Realtime
@ Realtime
Definition
Threading.h:42
Skyfire::Normal
@ Normal
Definition
Threading.h:39
Skyfire::Idle
@ Idle
Definition
Threading.h:36
src
server
shared
Threading
Threading.h
Generated on
for Project SkyFire Core by
1.17.0