Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
IArchMultithread Class Referenceabstract

Interface for architecture dependent multithreading. More...

#include <IArchMultithread.h>

Inheritance diagram for IArchMultithread:
Collaboration diagram for IArchMultithread:

Public Types

enum class  ThreadSignal : uint8_t {
  Interrupt , Terminate , Hangup , User ,
  MaxSignals
}
 Types of signals. More...
using ThreadFunc = void *(*)(void *)
 Type of thread entry point.
using ThreadID = unsigned int
 Type of thread identifier.
using SignalFunc = void (*)(ThreadSignal, void *userData)
 Type of signal handler function.

Public Member Functions

manipulators
virtual ArchCond newCondVar ()=0
 Create a condition variable.
virtual void closeCondVar (ArchCond)=0
 Destroy a condition variable.
virtual void signalCondVar (ArchCond)=0
 Signal a condition variable.
virtual void broadcastCondVar (ArchCond)=0
 Broadcast a condition variable.
virtual bool waitCondVar (ArchCond, ArchMutex, double timeout)=0
 Wait on a condition variable.
virtual ArchMutex newMutex ()=0
 Create a recursive mutex.
virtual void closeMutex (ArchMutex)=0
 Destroy a mutex.
virtual void lockMutex (ArchMutex)=0
 Lock a mutex.
virtual void unlockMutex (ArchMutex)=0
 Unlock a mutex.
virtual ArchThread newThread (ThreadFunc func, void *userData)=0
 Start a new thread.
virtual ArchThread newCurrentThread ()=0
 Get a reference to the calling thread.
virtual ArchThread copyThread (ArchThread thread)=0
 Copy a thread object.
virtual void closeThread (ArchThread)=0
 Release a thread reference.
virtual void cancelThread (ArchThread thread)=0
 Force a thread to exit.
virtual void setPriorityOfThread (ArchThread, int n)=0
 Change thread priority.
virtual void testCancelThread ()=0
 Cancellation point.
virtual bool wait (ArchThread thread, double timeout)=0
 Wait for a thread to exit.
virtual bool isSameThread (ArchThread, ArchThread)=0
 Compare threads.
virtual bool isExitedThread (ArchThread thread)=0
 Test if thread exited.
virtual void * getResultOfThread (ArchThread thread)=0
 Returns the exit code of a thread.
virtual ThreadID getIDOfThread (ArchThread thread)=0
 Returns an ID for a thread.
virtual void setSignalHandler (ThreadSignal, SignalFunc func, void *userData)=0
 Set the interrupt handler.
virtual void raiseSignal (ThreadSignal signal)=0
 Invoke the signal handler.
Public Member Functions inherited from IInterface
virtual ~IInterface ()=default
 Interface destructor does nothing.

Detailed Description

Interface for architecture dependent multithreading.

This interface defines the multithreading operations required by deskflow. Each architecture must implement this interface.

Member Typedef Documentation

◆ SignalFunc

using IArchMultithread::SignalFunc = void (*)(ThreadSignal, void *userData)

Type of signal handler function.

◆ ThreadFunc

using IArchMultithread::ThreadFunc = void *(*)(void *)

Type of thread entry point.

◆ ThreadID

using IArchMultithread::ThreadID = unsigned int

Type of thread identifier.

Member Enumeration Documentation

◆ ThreadSignal

enum class IArchMultithread::ThreadSignal : uint8_t
strong

Types of signals.

Not all platforms support all signals. Unsupported signals are ignored.

Enumerator
Interrupt 

Interrupt (e.g. Ctrl+C)

Terminate 

Terminate (e.g. Ctrl+Break)

Hangup 

Hangup (SIGHUP)

User 

User (SIGUSR2)

MaxSignals 

Number of differnt signals.

Member Function Documentation

◆ broadcastCondVar()

virtual void IArchMultithread::broadcastCondVar ( ArchCond )
pure virtual

Broadcast a condition variable.

Broadcasting a condition variable releases all waiting threads.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ cancelThread()

virtual void IArchMultithread::cancelThread ( ArchThread thread)
pure virtual

Force a thread to exit.

Causes thread to exit when it next calls a cancellation point. A thread avoids cancellation as long as it nevers calls a cancellation point. Once it begins the cancellation process it must always let cancellation go to completion but may take as long as necessary to clean up.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ closeCondVar()

virtual void IArchMultithread::closeCondVar ( ArchCond )
pure virtual

Destroy a condition variable.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ closeMutex()

virtual void IArchMultithread::closeMutex ( ArchMutex )
pure virtual

Destroy a mutex.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ closeThread()

virtual void IArchMultithread::closeThread ( ArchThread )
pure virtual

Release a thread reference.

Deletes the given thread object. This does not destroy the thread the object referred to, even if there are no remaining references. Use cancelThread() and waitThread() to stop a thread and wait for it to exit.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ copyThread()

virtual ArchThread IArchMultithread::copyThread ( ArchThread thread)
pure virtual

Copy a thread object.

Returns a reference to to thread referred to by thread.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ getIDOfThread()

virtual ThreadID IArchMultithread::getIDOfThread ( ArchThread thread)
pure virtual

Returns an ID for a thread.

Returns some ID number for thread. This is for logging purposes. All thread objects referring to the same thread return the same ID. However, clients should us isSameThread() to compare thread objects instead of comparing IDs.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ getResultOfThread()

virtual void * IArchMultithread::getResultOfThread ( ArchThread thread)
pure virtual

Returns the exit code of a thread.

Waits indefinitely for thread to exit (if it hasn't yet) then returns the thread's exit code.

(Cancellation point)

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ isExitedThread()

virtual bool IArchMultithread::isExitedThread ( ArchThread thread)
pure virtual

Test if thread exited.

Returns true iff thread has exited.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ isSameThread()

virtual bool IArchMultithread::isSameThread ( ArchThread ,
ArchThread  )
pure virtual

Compare threads.

Returns true iff two thread objects refer to the same thread. Note that comparing thread objects directly is meaningless.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ lockMutex()

virtual void IArchMultithread::lockMutex ( ArchMutex )
pure virtual

Lock a mutex.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ newCondVar()

virtual ArchCond IArchMultithread::newCondVar ( )
pure virtual

Create a condition variable.

The condition variable is an opaque data type.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ newCurrentThread()

virtual ArchThread IArchMultithread::newCurrentThread ( )
pure virtual

Get a reference to the calling thread.

Returns a thread representing the current (i.e. calling) thread.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ newMutex()

virtual ArchMutex IArchMultithread::newMutex ( )
pure virtual

Create a recursive mutex.

Creates a recursive mutex. A thread may lock a recursive mutex when it already holds a lock on that mutex. The mutex is an opaque data type.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ newThread()

virtual ArchThread IArchMultithread::newThread ( ThreadFunc func,
void * userData )
pure virtual

Start a new thread.

Creates and starts a new thread, using func as the entry point and passing it userData. The thread is an opaque data type.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ raiseSignal()

virtual void IArchMultithread::raiseSignal ( ThreadSignal signal)
pure virtual

Invoke the signal handler.

Invokes the signal handler for signal, if any. If no handler cancels the main thread for ThreadSignal::Interrupt and ThreadSignal::Terminate and ignores the call otherwise.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ setPriorityOfThread()

virtual void IArchMultithread::setPriorityOfThread ( ArchThread ,
int n )
pure virtual

Change thread priority.

Changes the priority of thread by n. If n is positive the thread has a lower priority and if negative a higher priority. Some architectures may not support either or both directions.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ setSignalHandler()

virtual void IArchMultithread::setSignalHandler ( ThreadSignal ,
SignalFunc func,
void * userData )
pure virtual

Set the interrupt handler.

Sets the function to call on receipt of an external interrupt. By default and when func is nullptr, the main thread is cancelled.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ signalCondVar()

virtual void IArchMultithread::signalCondVar ( ArchCond )
pure virtual

Signal a condition variable.

Signalling a condition variable releases one waiting thread.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ testCancelThread()

virtual void IArchMultithread::testCancelThread ( )
pure virtual

Cancellation point.

This method does nothing but is a cancellation point. Clients can make their own functions cancellation points by calling this method at appropriate times.

(Cancellation point)

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ unlockMutex()

virtual void IArchMultithread::unlockMutex ( ArchMutex )
pure virtual

Unlock a mutex.

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ wait()

virtual bool IArchMultithread::wait ( ArchThread thread,
double timeout )
pure virtual

Wait for a thread to exit.

Waits for up to timeout seconds for thread to exit (normally or by cancellation). Waits forever if timeout < 0. Returns true if the thread exited, false otherwise. Waiting on the current thread returns immediately with false.

(Cancellation point)

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.

◆ waitCondVar()

virtual bool IArchMultithread::waitCondVar ( ArchCond ,
ArchMutex ,
double timeout )
pure virtual

Wait on a condition variable.

Wait on a conditation variable for up to timeout seconds. If timeout is < 0 then there is no timeout. The mutex must be locked when this method is called. The mutex is unlocked during the wait and locked again before returning. Returns true if the condition variable was signalled and false on timeout.

(Cancellation point)

Implemented in ArchMultithreadPosix, and ArchMultithreadWindows.


The documentation for this class was generated from the following file: