Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
xosoperation.h
1//
2// xosoperation.h
3// general os dependent operations
4//
5// Created by Mootools on 20/05/2016.
6// Copyright © 2016 Mootools. All rights reserved.
7//
8
9#ifndef xosoperation_h
10#define xosoperation_h
11
12BEGIN_MOOTOOLS_NAMESPACE
13
14// thread
15#ifdef __WINDOWS__
16typedef HANDLE xThreadHandle;
17typedef longuint xThreadID;
18#elif defined(__APPLE__)
20typedef longuint xThreadID;
21#elif defined(__LINUX__)
23typedef pthread_t xThreadID; // Same things than xThreadHandle
24#endif
25
26typedef bool (*XTHREADPROC)(void *);
27
28#define XTHREAD_UNDEFINED_ID 0
29
30typedef enum
31{
32 XTHREAD_DEFAULT = 0,
33 XTHREAD_SUSPENDED = 0x01, // Thread should be started manually
34 XTHREAD_PREVENT_AUTODELETE = 0x02, // The thread object is not destroyed, unless it fails to init. This can be used when thread is embedded in a C++ object
35
36 // Private flags,
37 XTHREAD_RUNNING_HANDLE = 0x100, // Set when thread handle is running. If not set, the thread is considered as finished and is in exiting phase
38} xThreadFlags;
39
40typedef enum
41{
42 XTHREAD_PRIORITY_UNKNOWN = 0,
43 XTHREAD_PRIORITY_LOWEST,
44 XTHREAD_PRIORITY_LOW,
45 XTHREAD_PRIORITY_NORMAL,
46 XTHREAD_PRIORITY_HIGH,
47 XTHREAD_PRIORITY_HIGHEST,
48} xThreadPriority;
49
50typedef struct xThreadContext
51{
52 xThreadHandle handle;
53 unsigned int flags;
54 xThreadPriority priority;
55 xThreadID id;
56} xThreadContext;
57
58xThreadID xThreadGetCurrentID();
59void xThreadSleepCurrentThread(unsigned int milliSeconds);
60bool xThreadOpen(xThreadContext& threadCtxt, XTHREADPROC threadCallback, void *threadData, xThreadPriority priority, unsigned int flags, SIZET stacksize);
61bool xThreadClose(xThreadContext& threadCtxt);
62bool xThreadIsValid(const xThreadContext& threadCtxt);
63bool xThreadIsSuspended(const xThreadContext& threadCtxt);
64bool xThreadResume(xThreadContext& threadCtxt);
65bool xThreadSuspend(xThreadContext& threadCtxt);
66bool xThreadSetPriority(xThreadContext& threadCtxt, xThreadPriority priority);
67bool xThreadTerminate(xThreadID threadID); // Terminates hardly the thread. Return false if not possible, true if possible and succeed
68bool xThreadTerminate(xThreadHandle threadHandle); // Terminates hardly the thread. Return false if not possible, true if possible and succeed
69#ifdef _DEBUG
70DLL_TOOLSFUNCTION void xThreadSetName(xThreadID threadID, const char* threadName); // Set a thread name, if possible for debugging purpose
71#endif
72
73// Critical section & locks
74bool xInitCriticalSection(xCriticalSection& section);
75bool xDeleteCriticalSection(xCriticalSection& section);
76bool xLockCriticalSection(xCriticalSection& section);
77bool xUnlockCriticalSection(xCriticalSection& section);
78
79bool xGetLastOSErrorString(CXString& errorMessage); // return true if OS can provide a textual information on the last error, and then errorMessage is filled with that error. false if the feature is not supported by the OS
80
81#ifdef _DEBUG
82// Debug
83void xDebugOutputString(const CXString& string);
85#endif
86
87END_MOOTOOLS_NAMESPACE
88
89#endif /* xosoperation_h */
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27