| Qore Programming Language - C/C++ Library 1.12.2

Public Member Functions | List of all members
QoreForeignThreadHelper Class Reference

use this class to temporarily register and deregister a foreign thread to allow Qore code to be executed and the Qore library to be used from threads not created by the Qore library More...

`#include <qore_thread.h>`

## Public Member Functions
DLLEXPORT | QoreForeignThreadHelper ()
| registers the current thread as a foreign thread More...
DLLEXPORT | QoreForeignThreadHelper (int tid)
| registers the current thread as a foreign thread More...
DLLEXPORT | ~QoreForeignThreadHelper ()
| deregisters the current thread More...
DLLEXPORT | operator bool () const
| returns true if the object is valid, false if not

## Detailed Description

use this class to temporarily register and deregister a foreign thread to allow Qore code to be executed and the Qore library to be used from threads not created by the Qore library

Since
  Qore 0.8.7

## Constructor & Destructor Documentation

## ◆ QoreForeignThreadHelper() [1/2]

DLLEXPORT QoreForeignThreadHelper::QoreForeignThreadHelper | ( |  | ) |

registers the current thread as a foreign thread

the thread will be deregistered with q_deregister_foreign_thread() in the destructor

Since
  Qore 1.0.10 TID are reassigned if possible in order to support Qore thread affinity in language modules

## ◆ QoreForeignThreadHelper() [2/2]

DLLEXPORT QoreForeignThreadHelper::QoreForeignThreadHelper | ( | int | tid | ) |
| explicit

registers the current thread as a foreign thread

The tid given must be already reserved with q_reserve_foreign_thread_id(); the thread will be deregistered with q_deregister_reserved_foreign_thread() in the destructor

## ◆ ~QoreForeignThreadHelper()

DLLEXPORT QoreForeignThreadHelper::~QoreForeignThreadHelper | ( |  | ) |

deregisters the current thread

deregistration is only performed if the original registration in the constructor was successful. In this case either q_deregister_foreign_thread() or q_reserve_foreign_thread_id() will be called, depending on the action taken in the constructor

The documentation for this class was generated from the following file:

- include/qore/qore_thread.h