34 #ifndef _QORE_QORE_THREAD_H 35 #define _QORE_QORE_THREAD_H 47 class AbstractQoreZoneInfo;
48 class ThreadCleanupNode;
70 DLLEXPORT
int gettid() noexcept;
81 DLLEXPORT const AbstractQoreZoneInfo*
currentTZ();
130 DLLEXPORT
int remove_thread_resource_id(
q_trid_t trid);
136 DLLEXPORT
bool check_thread_resource_id(
q_trid_t trid);
152 static ThreadCleanupNode *head;
157 DLLLOCAL
void exec();
168 DLLEXPORT
void pop(
bool exec =
true);
179 #define QFT_REGISTERED -2 259 DLLLOCAL
void*
operator new(size_t);
262 class qore_foreign_thread_priv* priv;
275 typedef std::function<void(void*)> q_thread_local_destructor;
282 q_thread_local_destructor destructor;
284 DLLLOCAL
q_user_tld(
void* data, q_thread_local_destructor destructor);
307 DLLEXPORT
void*
q_swap_thread_local_data(
int key,
void* new_data, q_thread_local_destructor destructor =
nullptr,
bool run_destructor =
true);
340 #endif // ifndef _QORE_THREAD_H void(* qtdest_t)(void *)
pointer to a qore thread destructor function
Definition: qore_thread.h:52
base class for saving data using Qore's thread resource management system
Definition: AbstractThreadResource.h:51
DLLEXPORT int q_get_unique_thread_local_data_key()
returns a unique ID to use with thread_local_data APIs
DLLEXPORT int q_reserve_foreign_thread_id()
reserves a thread ID for later registration and returns the TID reserved; use q_release_reserved_fore...
DLLEXPORT void pop(bool exec=true)
must only be called in the module destructor/deletion function
DLLEXPORT ~QoreForeignThreadHelper()
deregisters the current thread if the registration was successful using either q_deregister_foreign_t...
DLLEXPORT void * q_swap_thread_local_data(int key, void *new_data, q_thread_local_destructor destructor=nullptr, bool run_destructor=true)
swaps thread-local data
DLLEXPORT int gettid() noexcept
DLLEXPORT bool check_thread_resource(AbstractThreadResource *atr)
check if a thread resouce has been saved
DLLEXPORT ThreadCleanupList tclist
the interface to the thread cleanup list
DLLEXPORT void set_thread_resource(AbstractThreadResource *atr)
save a resource against a thread for thread resource handling
int q_start_thread(ExceptionSink *xsink, q_thread_t f, void *arg=nullptr)
starts a new thread with the given arguments, when the thread terminates, it deregisters itself ...
DLLEXPORT void push(qtdest_t func, void *arg)
must only be called in the module initialization function
DLLEXPORT int remove_thread_resource(AbstractThreadResource *atr)
remove the resource from the thread resource list for the current thread
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram
DLLEXPORT int q_deregister_foreign_thread()
deregisters the current thread as a foreign thread
DLLEXPORT int q_release_reserved_foreign_thread_id(int tid)
releases a TID reserved with q_reserve_foreign_thread_id()
void(* qtrdest_t)(void *, ExceptionSink *)
pointer to a qore thread resource destructor function
Definition: qore_thread.h:55
unsigned q_trid_t
type for thread resource IDs (unique within a single running qore library process) ...
Definition: common.h:463
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:126
DLLEXPORT int q_remove_thread_local_data(int key, q_user_tld &data, bool run_destructor=true)
returns and removes thread-local data
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
DLLEXPORT QoreForeignThreadHelper()
registers the current thread as a foreign thread; the thread will be deregistered with q_deregister_f...
list of functions to be run when a thread ends; required for some external libraries that require exp...
Definition: qore_thread.h:150
void(* q_thread_t)(ExceptionSink *xsink, void *arg)
pointer to a function that can be started with q_start_thread()
Definition: qore_thread.h:58
DLLEXPORT q_user_tld * q_get_thread_local_data_all(int key)
returns thread-local data
base class for resolved call references
Definition: CallReferenceNode.h:105
DLLEXPORT void q_save_thread_local_data(int key, void *data, q_thread_local_destructor destructor=nullptr)
saves thread-local data
DLLEXPORT int q_register_foreign_thread()
registers the current thread as a Qore thread; returns QFT_OK (0) if the thread was successfully regi...
use this class to temporarily register and deregister a foreign thread to allow Qore code to be execu...
Definition: qore_thread.h:254
DLLEXPORT q_trid_t qore_get_trid()
get a thread resource ID
DLLEXPORT int q_deregister_reserved_foreign_thread()
deregisters a foreign qore thread but retains the TID as reserved
data structure for user thread-local data
Definition: qore_thread.h:280
DLLEXPORT void * q_get_thread_local_data(int key)
returns thread-local data
DLLEXPORT int q_gettid() noexcept
returns the current TID number
DLLEXPORT int q_register_reserved_foreign_thread(int tid)
registers a foreign qore thread as a Qore thread with a reserved TID
DLLEXPORT bool is_valid_qore_thread()
returns true if the current thread is a valid qore thread; it is not safe to call most Qore functions...
DLLEXPORT const AbstractQoreZoneInfo * currentTZ()
returns the current local time zone, note that if 0 = UTC