Deskflow 1.24.0.365
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
Arch.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
4 * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
5 * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
6 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7 */
8
9// Consider whether or not to use either encapsulation (as below)
10// or inheritance (as it is now) for the ARCH stuff.
11//
12// case for encapsulation:
13// pros:
14// - compiler errors for missing pv implementations are not absolutely bonkers.
15// - function names don't have to be so verbose.
16// - easier to understand and debug.
17// - ctors in IArch implementations can call other implementations.
18// cons:
19// - slightly more code for calls to ARCH.
20// - you'll have to modify each ARCH call.
21//
22// also, we may want to consider making each encapsulated
23// class lazy-loaded so that apps like the daemon don't load
24// stuff when they don't need it.
25
26#pragma once
27
28#if SYSAPI_WIN32
29
34
35#elif SYSAPI_UNIX
36
37#include "arch/ArchDaemonNone.h"
41
42#endif
43
48#define ARCH (Arch::getInstance())
49
51
60class Arch : public ARCH_DAEMON, public ARCH_LOG, public ARCH_MULTITHREAD, public ARCH_NETWORK
61{
62public:
63 Arch();
64 ~Arch() override = default;
65
66#if SYSAPI_WIN32
68
72 void init() override;
73#endif
74
75 //
76 // accessors
77 //
78
80
84 static Arch *getInstance();
85
90 static void sleep(double timeout);
91
97 static double time();
98
99private:
100 static Arch *s_instance;
101};
102
105{
106public:
107 explicit ArchMutexLock(ArchMutex mutex) : m_mutex(mutex)
108 {
109 ARCH->lockMutex(m_mutex);
110 }
111 ArchMutexLock(ArchMutexLock const &) = delete;
114 {
115 ARCH->unlockMutex(m_mutex);
116 }
117
120
121private:
122 ArchMutex m_mutex;
123};
#define ARCH_DAEMON
Definition ArchDaemonNone.h:13
#define ARCH_LOG
Definition ArchLogUnix.h:12
#define ARCH_MULTITHREAD
Definition ArchMultithreadPosix.h:16
#define ARCH_NETWORK
Definition ArchNetworkBSD.h:18
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:40
#define ARCH
Definition Arch.h:48
ArchMutexImpl * ArchMutex
Opaque mutex type. An opaque type representing a mutex.
Definition IArchMultithread.h:40
ArchMutexLock & operator=(ArchMutexLock const &)=delete
ArchMutexLock & operator=(ArchMutexLock &&)=delete
ArchMutexLock(ArchMutexLock &&)=delete
~ArchMutexLock()
Definition Arch.h:113
ArchMutexLock(ArchMutexLock const &)=delete
ArchMutexLock(ArchMutex mutex)
Definition Arch.h:107
static double time()
time
Definition Arch.cpp:52
static Arch * getInstance()
Return the singleton instance.
Definition Arch.cpp:37
~Arch() override=default
Arch()
Definition Arch.cpp:23
static void sleep(double timeout)
blocks calling thread for timout seconds
Definition Arch.cpp:43