Qore Programming Language Reference Manual 2.0.0
|
Functions | |
bool | Qore::active_exception () |
Returns True if there is an active exception for the current thread. | |
nothing | Qore::delete_all_thread_data () |
Deletes all keys in the thread-local data hash. | |
nothing | Qore::delete_thread_data (...) |
Deletes the data associated to one or more keys in the thread-local data hash; if the data is an object, then it is destroyed. | |
nothing | Qore::delete_thread_data (list< softstring > l) |
Deletes the data associated to one or more keys in the thread-local data hash; if the data is an object, then it is destroyed. | |
hash< string, list< hash< CallStackInfo > > > | Qore::getAllThreadCallStacks () |
Returns a hash of lists of CallStackInfo hashes keyed by TID (thread ID) | |
hash< string, list< hash< CallStackInfo > > > | Qore::get_all_thread_call_stacks () |
Returns a hash of lists of CallStackInfo hashes keyed by TID (thread ID) | |
hash< auto > | Qore::get_all_thread_data () |
Returns the entire thread-local data hash. | |
int | Qore::get_default_thread_stack_size () |
returns the default thread stack size | |
__7_ hash< CallStackInfo > | Qore::get_parent_caller_location (int offset=1) |
Returns information about the code in the callstack according to the offset argument. | |
int | Qore::get_stack_size () |
returns the current thread's stack size | |
list< hash< CallStackInfo > > | Qore::get_thread_call_stack () |
Returns a list of CallStackInfo hashes for the current TID (thread ID) | |
auto | Qore::get_thread_data (string key) |
Returns the value of the thread-local data attached to the key passed. | |
nothing | Qore::get_thread_data () |
This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. | |
__7_ string | Qore::get_thread_name () |
returns the current thread's descriptive name if set or NOTHING if not | |
__7_ TimeZone | Qore::get_thread_tz () |
Returns any TimeZone set for the current thread, NOTHING if none is set. | |
int | Qore::gettid () |
Returns the Qore thread ID (TID) of the current thread. | |
nothing | Qore::mark_thread_resources () |
Marks thread resources so that any thread resources left allocated after this call will be cleaned up when throw_thread_resource_exceptions_to_mark() is called. | |
int | Qore::num_threads () |
Returns the current number of threads in the process (not including the special signal handling thread) | |
__7_ hash< auto > | Qore::remove_thread_data (...) |
Removes the data associated to one or more keys in the thread-local data hash and returns the data removed. | |
hash< auto > | Qore::remove_thread_data (list< softstring > l) |
Removes the data associated to one or more keys in the thread-local data hash from a literal list passed as the first argument and returns the data removed. | |
bool | Qore::remove_thread_resource (AbstractThreadResource resource) |
removes a thread resource from the current thread | |
bool | Qore::remove_thread_resource (code resource) |
removes a callable thread resource from the current thread | |
nothing | Qore::save_thread_data (hash< auto > h) |
Saves the data passed in the thread-local hash; all keys are merged into the thread-local hash, overwriting any information that may have been there before. | |
nothing | Qore::save_thread_data (string key, auto value) |
Saves the data passed against the key passed as an argument in thread-local storage. | |
nothing | Qore::save_thread_data () |
This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. | |
int | Qore::set_default_thread_stack_size (int size) |
sets the default thread stack size for new threads created after this call and returns the stack size actually set | |
bool | Qore::set_thread_init (__7_ code init) |
Sets a call reference or closure to run every time a new thread is started. | |
nothing | Qore::set_thread_name (string name) |
sets the current thread's descriptive name | |
nothing | Qore::set_thread_resource (AbstractThreadResource resource) |
sets a thread resource for the current thread | |
nothing | Qore::set_thread_resource (code resource, auto arg) |
sets a callable thread resource for the current thread with an optional argument | |
nothing | Qore::set_thread_tz (TimeZone zone) |
Sets the default time zone for the current thread. | |
nothing | Qore::set_thread_tz () |
Clears the thread-local time zone for the current thread; after this call TimeZone::get() will return the value set for the current Program. | |
list< int > | Qore::thread_list () |
Returns a list of all current thread IDs. | |
nothing | Qore::thread_yield () |
yields the current thread so other threads can be scheduled and run | |
nothing | Qore::throwThreadResourceExceptions () |
Immediately runs all thread resource cleanup routines for the current thread and throws all associated exceptions. | |
nothing | Qore::throw_thread_resource_exceptions () |
Immediately runs all thread resource cleanup routines for the current thread and throws all associated exceptions. | |
bool | Qore::throw_thread_resource_exceptions_to_mark () |
Immediately runs all thread resource cleanup routines for the current thread for thread resources created since the last call to mark_thread_resources() and throws all associated exceptions. | |
Threading functions
bool Qore::active_exception | ( | ) |
Returns True if there is an active exception for the current thread.
Can be run in destructors or thread cleanup code to determine if an exception is active
nothing Qore::delete_all_thread_data | ( | ) |
Deletes all keys in the thread-local data hash.
nothing Qore::delete_thread_data | ( | ... | ) |
Deletes the data associated to one or more keys in the thread-local data hash; if the data is an object, then it is destroyed.
... | Deletes the data associated to one or more keys in the thread-local data hash corresponding to each string argument in the top-level argument list; arguments are converted to strings if necessary |
nothing Qore::delete_thread_data | ( | list< softstring > | l | ) |
Deletes the data associated to one or more keys in the thread-local data hash; if the data is an object, then it is destroyed.
l | a list of key names for deleting keys in the thread-local data hash; values are converted to strings if necessary |
hash< string, list< hash< CallStackInfo > > > Qore::get_all_thread_call_stacks | ( | ) |
Returns a hash of lists of CallStackInfo hashes keyed by TID (thread ID)
Returns the entire thread-local data hash.
int Qore::get_default_thread_stack_size | ( | ) |
returns the default thread stack size
__7_ hash< CallStackInfo > Qore::get_parent_caller_location | ( | int | offset = 1 | ) |
Returns information about the code in the callstack according to the offset argument.
offset | the offset in the call stack to retrieve |
int Qore::get_stack_size | ( | ) |
returns the current thread's stack size
list< hash< CallStackInfo > > Qore::get_thread_call_stack | ( | ) |
Returns a list of CallStackInfo hashes for the current TID (thread ID)
Because it is always from the same thread being read, no locking is applied as in get_all_thread_call_stacks()
nothing Qore::get_thread_data | ( | ) |
This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
Returns the value of the thread-local data attached to the key passed.
returns the current thread's descriptive name if set or NOTHING if not
qore/
tid where tid is the current thread IDReturns any TimeZone set for the current thread, NOTHING if none is set.
hash< string, list< hash< CallStackInfo > > > Qore::getAllThreadCallStacks | ( | ) |
Returns a hash of lists of CallStackInfo hashes keyed by TID (thread ID)
int Qore::gettid | ( | ) |
Returns the Qore thread ID (TID) of the current thread.
nothing Qore::mark_thread_resources | ( | ) |
Marks thread resources so that any thread resources left allocated after this call will be cleaned up when throw_thread_resource_exceptions_to_mark() is called.
When exceptions are thrown by this function, thread-local resources are also cleaned up at the same time.
int Qore::num_threads | ( | ) |
Returns the current number of threads in the process (not including the special signal handling thread)
Removes the data associated to one or more keys in the thread-local data hash and returns the data removed.
... | the key names should be given directly in the argument list with this variant. If the given hash keys do not exist in the thread-local data hash, then the given key in the return value will have no value assigned |
hash< auto > Qore::remove_thread_data | ( | list< softstring > | l | ) |
Removes the data associated to one or more keys in the thread-local data hash from a literal list passed as the first argument and returns the data removed.
l | a list of key names to remove from the thread-local data hash. If the given hash keys do not exist in the thread-local data hash, then the given key in the return value will have no value assigned |
bool Qore::remove_thread_resource | ( | AbstractThreadResource | resource | ) |
removes a thread resource from the current thread
resource | the thread resource to remove |
bool Qore::remove_thread_resource | ( | code | resource | ) |
removes a callable thread resource from the current thread
resource | the callable thread resource to remove |
nothing Qore::save_thread_data | ( | ) |
This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
Saves the data passed in the thread-local hash; all keys are merged into the thread-local hash, overwriting any information that may have been there before.
h | a hash of data to save in the thread-local data hash |
Saves the data passed against the key passed as an argument in thread-local storage.
key | the name of the key in the thread-local hash to save the data against |
value | the value to save in the thread-local hash against the key |
sets the default thread stack size for new threads created after this call and returns the stack size actually set
size | the size in bytes for new threads |
SET-DEFAULT-THREAD-STACK-SIZE-ERROR | an error occurred setting the default thread stack size |
Sets a call reference or closure to run every time a new thread is started.
This code can be used to initialize global thread-local variables, for example.
init | a call reference or closure to run every time a new thread is started or NOTHING to clear any thread initialization code |
sets the current thread's descriptive name
name | the new descriptive name for the thread |
nothing Qore::set_thread_resource | ( | AbstractThreadResource | resource | ) |
sets a thread resource for the current thread
resource | the thread resource to set |
sets a callable thread resource for the current thread with an optional argument
resource | the thread resource handler to set |
arg | an argument to use when calling the thread resource handler |
nothing Qore::set_thread_tz | ( | ) |
Clears the thread-local time zone for the current thread; after this call TimeZone::get() will return the value set for the current Program.
Sets the default time zone for the current thread.
zone | the TimeZone object for the current thread |
This will cause the TimeZone::get() method to return the given TimeZone when called from the same thread
Returns a list of all current thread IDs.
Note that the special signal handling thread with TID 0 is never included in the list returned by this function
nothing Qore::thread_yield | ( | ) |
yields the current thread so other threads can be scheduled and run
nothing Qore::throw_thread_resource_exceptions | ( | ) |
Immediately runs all thread resource cleanup routines for the current thread and throws all associated exceptions.
This function is particularly useful when used in combination with embedded code in order to catch (and log, for example) thread resource errors (ex: uncommitted transactions, unlocked locks, etc) - this can be used when control returns to the "master" program to ensure that no thread-local resources have been left active.
This function will run all thread resource cleanup routines even if mark_thread_resources() has been called (i.e. it clears all marks as well).
When exceptions are thrown by this function, thread-local resources are also cleaned up at the same time.
bool Qore::throw_thread_resource_exceptions_to_mark | ( | ) |
Immediately runs all thread resource cleanup routines for the current thread for thread resources created since the last call to mark_thread_resources() and throws all associated exceptions.
When exceptions are thrown by this function, thread-local resources are also cleaned up at the same time.
nothing Qore::throwThreadResourceExceptions | ( | ) |
Immediately runs all thread resource cleanup routines for the current thread and throws all associated exceptions.
This function is particularly useful when used in combination with embedded code in order to catch (and log, for example) thread resource errors (ex: uncommitted transactions, unlocked locks, etc) - this can be used when control returns to the "master" program to ensure that no thread-local resources have been left active.
This function will run all thread resource cleanup routines even if mark_thread_resources() has been called (i.e. it clears all marks as well).
When exceptions are thrown by this function, thread-local resources are also cleaned up at the same time.