UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
pthread.hpp
Go to the documentation of this file.
1#ifndef UPnPsdk_PTHREAD_HPP
2#define UPnPsdk_PTHREAD_HPP
3// Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
4// Redistribution only with this Copyright remark. Last modified: 2025-06-11
5
11#include <UPnPsdk/visibility.hpp> // needed for some platforms
13#include "pthread.h" // To find pthreads4w don't use <pthread.h>
14#include <cstdint>
16
17namespace UPnPsdk {
19namespace {
20
21/****************************************************************************
22 * Function: initialize_thread
23 *
24 * Description:
25 * Initializes the thread. Does nothing in all implementations, except
26 * when statically linked for WIN32. For details have a look at
27 * build/_deps/pthreads4w-src/README.NONPORTABLE.
28 * Parameters:
29 * none.
30 * Returns:
31 * always 0 (pthread_win32_thread_attach_np() always returns true).
32 ***************************************************************************/
33inline int initialize_thread() {
34#if defined(_WIN32) && defined(PTW32_STATIC_LIB)
35 return !pthread_win32_thread_attach_np();
36#else
37 return 0;
38#endif
39}
40
41/****************************************************************************
42 * Function: cleanup_thread
43 *
44 * Description:
45 * Clean up thread resources. Does nothing in all implementations, except
46 * when statically linked for WIN32. For details have a look at
47 * build/_deps/pthreads4w-src/README.NONPORTABLE.
48 * Parameters:
49 * none.
50 * Returns:
51 * always 0 (pthread_win32_thread_detach_np() always returns true).
52 ***************************************************************************/
53inline int cleanup_thread() {
54#if defined(_WIN32) && defined(PTW32_STATIC_LIB)
55 return !pthread_win32_thread_detach_np();
56#else
57 return 0;
58#endif
59}
60
61} // namespace
62
63
64/****************************************************************************
65 * Name: start_routine
66 *
67 * Description:
68 * Thread start routine
69 * Internal Use Only.
70 ***************************************************************************/
71typedef void (*start_routine)(void* arg);
72
74
75
76#if defined(_MSC_VER) || defined(__APPLE__) || defined(DOXYGEN_RUN)
89UPnPsdk_VIS uint64_t pthread_self();
90#endif
91
92
104 public:
107 ::pthread_mutex_t& a_mutex );
110
111 private:
112 ::pthread_mutex_t& m_mutex;
113};
114
115} // namespace UPnPsdk
116
117#endif /* UPnPsdk_PTHREAD_HPP */
Scoped POSIX thread mutex lock is valid for the current scope of the object.
Definition pthread.hpp:103
~CPthread_scoped_lock()
Unlock the mutex that was locked by the constructor.
Definition pthread.cpp:37
Reengineered Object Oriented UPnP+ program code.
UPnPsdk_VIS uint64_t pthread_self()
Get pthread thread id as unsigned integer.
Definition pthread.cpp:20
Macros to support visibility of external symbols.
#define UPnPsdk_VIS
Prefix to export symbol for external use.