Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
Thread.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
4 * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
5 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6 */
7
8#pragma once
9
11
12class IJob;
13
15
31// note -- do not derive from this class
32class Thread
33{
34public:
36
40 explicit Thread(IJob *adoptedJob);
41
43
47 Thread(const Thread &);
48
50
55 ~Thread();
56
58
59
61
66 Thread &operator=(const Thread &);
67
69
81 [[noreturn]] static void exit(void *);
82
84
109 void cancel();
110
112
117 void setPriority(int n);
118
120
124 void unblockPollSocket();
125
127
129
131
134 static Thread getCurrentThread();
135
137
145 static void testCancel();
146
148
158 bool wait(double timeout = -1.0) const;
159
161
168 void *getResult() const;
169
171
177
179
182 bool operator==(const Thread &) const;
183
185
188 bool operator!=(const Thread &) const;
189
191
192private:
193 explicit Thread(ArchThread);
194
195 static void *threadFunc(void *);
196
197private:
198 ArchThread m_thread = nullptr;
199};
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:39
ArchThreadImpl * ArchThread
Opaque thread type. An opaque type representing a thread.
Definition IArchMultithread.h:53
unsigned int ThreadID
Type of thread identifier.
Definition IArchMultithread.h:66
Job interface.
Definition IJob.h:17
Thread(IJob *adoptedJob)
Run adoptedJob in a new thread.
Definition Thread.cpp:21
~Thread()
Release a thread handle.
Definition Thread.cpp:41
static void exit(void *)
Terminate the calling thread.
Definition Thread.cpp:58
void unblockPollSocket()
Force pollSocket() to return.
Definition Thread.cpp:73
static Thread getCurrentThread()
Get current thread's handle.
Definition Thread.cpp:78
IArchMultithread::ThreadID getID() const
Get the thread id.
Definition Thread.cpp:101
bool operator==(const Thread &) const
Compare thread handles.
Definition Thread.cpp:106
bool wait(double timeout=-1.0) const
Wait for thread to terminate.
Definition Thread.cpp:88
void setPriority(int n)
Change thread priority.
Definition Thread.cpp:68
Thread & operator=(const Thread &)
Assign thread handle.
Definition Thread.cpp:46
void cancel()
Cancel thread.
Definition Thread.cpp:63
bool operator!=(const Thread &) const
Compare thread handles.
Definition Thread.cpp:111
static void testCancel()
Test for cancellation.
Definition Thread.cpp:83
void * getResult() const
Get the exit result.
Definition Thread.cpp:93