| 1 | // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/threads/fred.h`/ |
| 2 | |
| 3 | #ifndef HL_FRED_H |
| 4 | #define HL_FRED_Hcxx . . $ `vendor/Heap-Layers/threads/fred.h:4:9`! |
| 5 | |
| 6 | /// A thread-wrapper of childlike simplicity :). |
| 7 | |
| 8 | #if defined(_WIN32) |
| 9 | |
| 10 | #include <windows.h> |
| 11 | #include <process.h> |
| 12 | |
| 13 | #elif defined(__SVR4) |
| 14 | |
| 15 | #include <thread.h> |
| 16 | #include <pthread.h> |
| 17 | #include <unistd.h> |
| 18 | |
| 19 | #else |
| 20 | |
| 21 | #include <pthread.h> |
| 22 | #include <unistd.h> |
| 23 | |
| 24 | #endif |
| 25 | |
| 26 | extern "C" typedef void * (*ThreadFunctionType) (void *); |
| 27 | |
| 28 | namespace HLcxx . . $ HL/ { |
| 29 | |
| 30 | class Fredcxx . . $ HL/Fred# { |
| 31 | public: |
| 32 | |
| 33 | Fredcxx . . $ HL/Fred#Fred(49f6e7a06ebc5aa8).() { |
| 34 | #if !defined(_WIN32) |
| 35 | pthread_attr_init (&attrcxx . . $ HL/Fred#attr.); |
| 36 | #endif |
| 37 | } |
| 38 | |
| 39 | ~cxx . . $ HL/Fred#`~Fred`(49f6e7a06ebc5aa8).Fredcxx . . $ HL/Fred#() { |
| 40 | #if !defined(_WIN32) |
| 41 | pthread_attr_destroy (&attrcxx . . $ HL/Fred#attr.); |
| 42 | #endif |
| 43 | } |
| 44 | |
| 45 | void createcxx . . $ HL/Fred#create(fb7485594524cea5). (ThreadFunctionType function, void * arg) { |
| 46 | #if defined(_WIN32) |
| 47 | t = CreateThread (0, 0, (LPTHREAD_START_ROUTINE) *function, (LPVOID) arg, 0, 0); |
| 48 | #else |
| 49 | pthread_create (&tcxx . . $ HL/Fred#t., &attrcxx . . $ HL/Fred#attr., function, arg); |
| 50 | #endif |
| 51 | } |
| 52 | |
| 53 | void joincxx . . $ HL/Fred#join(49f6e7a06ebc5aa8).() { |
| 54 | #if defined(_WIN32) |
| 55 | WaitForSingleObject (t, INFINITE); |
| 56 | #else |
| 57 | pthread_join (tcxx . . $ HL/Fred#t., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 58 | #endif |
| 59 | } |
| 60 | |
| 61 | static void yieldcxx . . $ HL/Fred#yield(49f6e7a06ebc5aa8).() { |
| 62 | #if defined(_WIN32) |
| 63 | Sleep (0); |
| 64 | #elif defined(__SVR4) |
| 65 | thr_yield(); |
| 66 | #else |
| 67 | sched_yield(); |
| 68 | #endif |
| 69 | } |
| 70 | |
| 71 | |
| 72 | static void setConcurrencycxx . . $ HL/Fred#setConcurrency(d4f767463ce0a6b3). (int n) { |
| 73 | #if defined(_WIN32) |
| 74 | #elif defined(__SVR4) |
| 75 | thr_setconcurrency (n); |
| 76 | #elif !defined(__NetBSD__) |
| 77 | pthread_setconcurrency (n); |
| 78 | #endif |
| 79 | } |
| 80 | |
| 81 | |
| 82 | private: |
| 83 | |
| 84 | Fredcxx . . $ HL/Fred#Fred(7ae2a679bc093aea). (const Fredcxx . . $ HL/Fred#&); |
| 85 | Fredcxx . . $ HL/Fred#& operatorcxx . . $ HL/Fred#`operator=`(a7cb6b0c98affafd).=(const Fredcxx . . $ HL/Fred#&); |
| 86 | |
| 87 | #if defined(_WIN32) |
| 88 | typedef HANDLE FredType; |
| 89 | #else |
| 90 | typedef pthread_t FredTypecxx . . $ HL/Fred#FredType#; |
| 91 | pthread_attr_t attrcxx . . $ HL/Fred#attr.; |
| 92 | #endif |
| 93 | |
| 94 | FredTypecxx . . $ HL/Fred#FredType# tcxx . . $ HL/Fred#t.; |
| 95 | }; |
| 96 | |
| 97 | } |
| 98 | |
| 99 | |
| 100 | #endif |