34#ifndef _QORE_QORE_THREAD_INTERN_H
35#define _QORE_QORE_THREAD_INTERN_H
41#ifndef QORE_THREAD_STACK_SIZE
42#define QORE_THREAD_STACK_SIZE 1024*512
46#ifndef QORE_STACK_GUARD
48#define QORE_STACK_GUARD (1024 * 8)
58class ClosureParseEnvironment;
60hashdecl ClosureVarValue;
64class qore_root_ns_private;
65class qore_class_private;
66class AbstractQoreFunctionVariant;
67class AbstractQoreZoneInfo;
68class ThreadProgramData;
69hashdecl ThreadLocalProgramData;
70class QoreAbstractModule;
74DLLLOCAL
extern Operator* OP_BACKGROUND;
77class AbstractQoreZoneInfo;
80hashdecl ModuleContextNamespaceCommit {
81 qore_ns_private* parent;
84 DLLLOCAL ModuleContextNamespaceCommit(qore_ns_private* n_parent, qore_ns_private* n_nns) : parent(n_parent), nns(n_nns) {
88typedef std::vector<ModuleContextNamespaceCommit> mcnl_t;
90class ModuleContextNamespaceList :
public mcnl_t {
93 DLLLOCAL ModuleContextNamespaceList(
const ModuleContextNamespaceList&);
96 DLLLOCAL ModuleContextNamespaceList() {
99 DLLLOCAL ~ModuleContextNamespaceList() {
103 DLLLOCAL
void clear();
106hashdecl ModuleContextFunctionCommit {
107 qore_ns_private* parent;
109 AbstractQoreFunctionVariant* v;
111 DLLLOCAL ModuleContextFunctionCommit(qore_ns_private* n_parent,
const char* n_name, AbstractQoreFunctionVariant* n_v) : parent(n_parent), name(n_name), v(n_v) {
115typedef std::vector<ModuleContextFunctionCommit> mcfl_t;
117class ModuleContextFunctionList :
public mcfl_t {
120 DLLLOCAL ModuleContextFunctionList(
const ModuleContextFunctionList&);
123 DLLLOCAL ModuleContextFunctionList() {
126 DLLLOCAL ~ModuleContextFunctionList() {
130 DLLLOCAL
void clear();
133class QoreModuleContext {
135 ModuleContextNamespaceList mcnl;
136 ModuleContextFunctionList mcfl;
138 DLLLOCAL QoreModuleContext(
const char* n, qore_root_ns_private* n_rns,
ExceptionSink& xs);
140 DLLLOCAL ~QoreModuleContext() {
144 DLLLOCAL
void error(
const char* fmt, ...);
146 DLLLOCAL
bool hasError()
const {
150 DLLLOCAL
void commit();
152 DLLLOCAL
void rollback() {
157 DLLLOCAL qore_root_ns_private* getRootNS()
const {
161 DLLLOCAL
const char* getName()
const {
167 qore_root_ns_private* rns;
169 QoreModuleContext* parent;
173class QoreModuleDefContext {
175 typedef std::set<std::string> strset_t;
176 typedef std::map<std::string, std::string> strmap_t;
181 const QoreProgramLocation* init_loc =
nullptr,
184 DLLLOCAL QoreModuleDefContext() {
187 DLLLOCAL ~QoreModuleDefContext() {
193 static strset_t vset;
198 DLLLOCAL
int set(
const QoreProgramLocation* loc,
const char* key,
QoreValue val);
200 DLLLOCAL
const char* get(
const char* str)
const {
201 strmap_t::const_iterator i = vmap.find(str);
202 return i == vmap.end() || i->second.empty() ? nullptr : i->second.c_str();
205 DLLLOCAL
int parseInit();
207 DLLLOCAL
bool hasInit()
const {
208 return init_c ? true :
false;
216 DLLLOCAL
int initClosure(
const QoreProgramLocation* loc,
QoreValue& c,
const char* n);
222DLLLOCAL
void inc_active_exceptions(
int diff);
225DLLLOCAL
int purge_thread_resources_to_mark(
ExceptionSink* xsink);
228DLLLOCAL
void mark_thread_resources();
229DLLLOCAL
void beginParsing(
const char* file,
void* ps = NULL,
const char* src =
nullptr,
int offset = 0);
230DLLLOCAL
void* endParsing();
231DLLLOCAL Context* get_context_stack();
232DLLLOCAL
void update_context_stack(Context* cstack);
236 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm);
238 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm,
const QoreProgramLocation*& old_runtime_loc);
240DLLLOCAL
void update_runtime_stack_location(
const QoreStackLocation* stack_loc,
const QoreProgramLocation* runtime_loc);
242DLLLOCAL
const QoreProgramLocation* get_runtime_location();
243DLLLOCAL
int swap_runtime_statement_location(
ExceptionSink* xsink,
const AbstractStatement* stmt,
244 const QoreProgramLocation* loc,
int64 po,
const AbstractStatement*& old_stmt,
245 const QoreProgramLocation*& old_loc,
int64& old_po);
246DLLLOCAL
void swap_runtime_location(
const QoreProgramLocation*loc,
const AbstractStatement*& old_stmt,
247 const QoreProgramLocation*& old_loc);
248DLLLOCAL
void update_runtime_statement_location(
const AbstractStatement* stmt,
const QoreProgramLocation* loc,
int64 po);
249DLLLOCAL
void update_runtime_statement_location(
const AbstractStatement* stmt,
const QoreProgramLocation* loc);
251DLLLOCAL
void set_parse_file_info(QoreProgramLocation& loc);
252DLLLOCAL
const char* get_parse_code();
254DLLLOCAL
const AbstractStatement* get_runtime_statement();
256DLLLOCAL
const QoreTypeInfo* parse_set_implicit_arg_type_info(
const QoreTypeInfo* ti);
257DLLLOCAL
const QoreTypeInfo* parse_get_implicit_arg_type_info();
259DLLLOCAL
int64 parse_get_parse_options();
260DLLLOCAL
int64 runtime_get_parse_options();
263DLLLOCAL
bool parse_check_parse_option(
int64 o);
264DLLLOCAL
bool runtime_check_parse_option(
int64 o);
267DLLLOCAL
void updateCVarStack(CVNode* ncvs);
268DLLLOCAL CVNode* getCVarStack();
269DLLLOCAL
void updateVStack(VNode* nvs);
270DLLLOCAL VNode* getVStack();
274DLLLOCAL qore_class_private* parse_get_class_priv();
275DLLLOCAL
void thread_set_class_and_ns(
const qore_class_private* new_cls, qore_ns_private* new_ns,
const qore_class_private*& old_cls, qore_ns_private*& old_ns);
276DLLLOCAL
void thread_set_class_and_ns(
const qore_class_private* new_cls, qore_ns_private* new_ns);
277DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns, qore_ns_private*& old_ns);
278DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns);
279DLLLOCAL qore_ns_private* parse_get_ns();
281DLLLOCAL
void substituteObjectIfEqual(
QoreObject* o);
284DLLLOCAL QoreException* catch_swap_exception(QoreException* e);
285DLLLOCAL QoreException* catch_get_exception();
287DLLLOCAL VLock* getVLock();
289DLLLOCAL
void delete_thread_local_data();
290DLLLOCAL
void parse_cond_push(
bool mark =
false);
291DLLLOCAL
bool parse_cond_else();
292DLLLOCAL
bool parse_cond_pop(
const QoreProgramLocation* loc);
293DLLLOCAL
bool parse_cond_test(
const QoreProgramLocation* loc);
294DLLLOCAL
void push_parse_options();
295DLLLOCAL
void parse_try_module_inc();
296DLLLOCAL
bool parse_try_module_dec(
const QoreProgramLocation* loc);
297DLLLOCAL
unsigned parse_try_module_get();
298DLLLOCAL
void parse_try_module_set(
unsigned c);
300DLLLOCAL
void parse_push_name(
const char* name);
301DLLLOCAL std::string parse_pop_name(std::string& path);
303DLLLOCAL
void parse_push_ns_name(
const char* name);
304DLLLOCAL std::string parse_pop_ns_name(std::string& path);
306DLLLOCAL std::string get_ns_path(
const char* name);
308DLLLOCAL
void set_module_context(QoreModuleContext* qmc);
309DLLLOCAL QoreModuleContext* get_module_context();
310DLLLOCAL QoreModuleDefContext* set_module_def_context(QoreModuleDefContext* qmd);
311DLLLOCAL QoreModuleDefContext* get_module_def_context();
312DLLLOCAL
void parse_set_module_def_context_name(
const char* name);
313DLLLOCAL
const char* set_module_context_name(
const char* n);
314DLLLOCAL
const char* get_module_context_name();
316DLLLOCAL
void parse_set_try_reexport(
bool tr);
317DLLLOCAL
bool parse_get_try_reexport();
319DLLLOCAL
void set_thread_tz(
const AbstractQoreZoneInfo* tz);
320DLLLOCAL
const AbstractQoreZoneInfo* get_thread_tz(
bool& set);
321DLLLOCAL
void clear_thread_tz();
323DLLLOCAL ThreadProgramData* get_thread_program_data();
324DLLLOCAL ThreadLocalProgramData* get_thread_local_program_data();
326DLLLOCAL
int thread_ref_set(
const lvalue_ref* r);
327DLLLOCAL
void thread_ref_remove(
const lvalue_ref* r);
330DLLLOCAL
void new_argv_ref();
333DLLLOCAL
void inc_argv_ref();
336DLLLOCAL
void push_ignore_numeric_argv_ref();
339DLLLOCAL
void pop_ignore_numeric_argv_ref();
342DLLLOCAL
void inc_numeric_argv_ref();
345DLLLOCAL
int get_pop_argv_ref();
348DLLLOCAL
void clear_argv_ref();
350DLLLOCAL
int set_constant(ConstantEntry* ce);
351DLLLOCAL
void remove_constant(ConstantEntry* ce);
353DLLLOCAL QoreAbstractModule* set_reexport(QoreAbstractModule* m,
bool current_reexport,
bool& old_reexport);
354DLLLOCAL
void set_reexport(QoreAbstractModule* m,
bool reexport);
356DLLLOCAL
void parseSetCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo,
const char*& old_code,
const QoreTypeInfo*& old_returnTypeInfo);
357DLLLOCAL
void parseRestoreCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo);
359DLLLOCAL
const QoreTypeInfo* saveReturnTypeInfo(
const QoreTypeInfo* returnTypeInfo);
360DLLLOCAL
const QoreTypeInfo* getReturnTypeInfo();
362DLLLOCAL
const QoreTypeInfo* parse_get_return_type_info();
365DLLLOCAL
void set_program_call_context(
QoreProgram* new_pgm);
368class LVarStackBreakHelper {
370 DLLLOCAL LVarStackBreakHelper();
371 DLLLOCAL ~LVarStackBreakHelper();
377class ProgramCallContextHelper {
379 DLLLOCAL ProgramCallContextHelper(
QoreProgram* new_pgm);
380 DLLLOCAL ~ProgramCallContextHelper();
386class ModuleReExportHelper {
388 QoreAbstractModule* m;
392 DLLLOCAL ModuleReExportHelper(QoreAbstractModule* mi,
bool reexp);
393 DLLLOCAL ~ModuleReExportHelper();
396class QoreParseCountContextHelper {
401 DLLLOCAL QoreParseCountContextHelper() : count(parse_try_module_get()) {
402 parse_try_module_set(0);
405 DLLLOCAL ~QoreParseCountContextHelper() {
406 parse_try_module_set(count);
410class QoreProgramStackLocationHelper {
412 DLLLOCAL QoreProgramStackLocationHelper(
QoreStackLocation* stack_loc,
const AbstractStatement*& current_stmt,
414 stack_loc(update_get_runtime_stack_location(stack_loc, current_stmt, current_pgm)) {
417 DLLLOCAL ~QoreProgramStackLocationHelper() {
418 update_runtime_stack_location(stack_loc);
425class QoreInternalCallStackLocationHelperBase :
public QoreStackLocation,
public QoreProgramStackLocationHelper {
427 DLLLOCAL QoreInternalCallStackLocationHelperBase() : QoreProgramStackLocationHelper(this, stmt, pgm) {
434 DLLLOCAL
virtual const AbstractStatement*
getStatement()
const {
439 const AbstractStatement* stmt;
443class QoreInternalCallStackLocationHelper :
public QoreInternalCallStackLocationHelperBase {
445 DLLLOCAL QoreInternalCallStackLocationHelper(
const QoreProgramLocation& loc,
const std::string& call,
446 qore_call_t call_type) : loc(loc), call(call), call_type(call_type) {
450 DLLLOCAL
virtual const QoreProgramLocation& getLocation()
const {
455 DLLLOCAL
virtual const std::string& getCallName()
const {
459 DLLLOCAL
virtual qore_call_t getCallType()
const {
464 const QoreProgramLocation& loc;
465 const std::string call;
466 qore_call_t call_type;
469class QoreProgramLocationHelper {
471 DLLLOCAL QoreProgramLocationHelper(
ExceptionSink* xsink,
const QoreProgramLocation* loc,
472 const AbstractStatement* stat,
int64 parse_options) : has_po(true) {
473 swap_runtime_statement_location(xsink, stat, loc, parse_options, statement, this->loc,
474 this->parse_options);
477 DLLLOCAL QoreProgramLocationHelper(
const QoreProgramLocation* loc) : has_po(false) {
478 swap_runtime_location(loc, statement, this->loc);
481 DLLLOCAL ~QoreProgramLocationHelper() {
483 update_runtime_statement_location(statement, loc, parse_options);
485 update_runtime_statement_location(statement, loc);
490 const QoreProgramLocation* loc;
491 const AbstractStatement* statement;
496class QoreProgramOptionalLocationHelper {
498 DLLLOCAL QoreProgramOptionalLocationHelper(
const QoreProgramLocation* loc) : restore((bool)loc) {
500 swap_runtime_location(loc, statement, this->loc);
504 DLLLOCAL ~QoreProgramOptionalLocationHelper() {
506 update_runtime_statement_location(statement, loc);
511 const QoreProgramLocation* loc;
512 const AbstractStatement* statement;
517class CurrentProgramRuntimeParseContextHelper {
520 DLLEXPORT CurrentProgramRuntimeParseContextHelper();
522 DLLEXPORT ~CurrentProgramRuntimeParseContextHelper();
526 CurrentProgramRuntimeParseContextHelper(
const CurrentProgramRuntimeParseContextHelper&) =
delete;
527 void*
operator new(size_t) =
delete;
531class ParseImplicitArgTypeHelper {
533 DLLLOCAL ParseImplicitArgTypeHelper(
const QoreTypeInfo* ti) : ati(parse_set_implicit_arg_type_info(ti)) {
536 DLLLOCAL ~ParseImplicitArgTypeHelper() {
537 parse_set_implicit_arg_type_info(ati);
541 const QoreTypeInfo* ati;
545DLLLOCAL
int get_thread_entry(
bool reuse_last =
false);
547DLLLOCAL
int get_signal_thread_entry();
548DLLLOCAL
void deregister_signal_thread();
549DLLLOCAL
void register_thread(
int tid, pthread_t ptid,
QoreProgram* pgm,
bool foreign =
false);
550DLLLOCAL
void deregister_thread(
int tid);
551DLLLOCAL
void delete_signal_thread();
558DLLLOCAL
void pushBlock(block_list_t::iterator i);
560DLLLOCAL block_list_t::iterator popBlock();
562DLLLOCAL
void advance_on_block_exit();
564DLLLOCAL LocalVarValue* thread_instantiate_lvar();
565DLLLOCAL
void thread_uninstantiate_lvar(
ExceptionSink* xsink);
566DLLLOCAL
void thread_uninstantiate_self();
568DLLLOCAL
void thread_set_closure_parse_env(ClosureParseEnvironment* cenv);
569DLLLOCAL ClosureParseEnvironment* thread_get_closure_parse_env();
571DLLLOCAL ClosureVarValue* thread_instantiate_closure_var(
const char*
id,
const QoreTypeInfo* typeInfo,
QoreValue& nval,
bool assign);
572DLLLOCAL
void thread_instantiate_closure_var(ClosureVarValue* cvar);
573DLLLOCAL
void thread_uninstantiate_closure_var(
ExceptionSink* xsink);
574DLLLOCAL ClosureVarValue* thread_find_closure_var(
const char*
id);
576DLLLOCAL ClosureVarValue* thread_get_runtime_closure_var(
const LocalVar*
id);
577DLLLOCAL
const QoreClosureBase* thread_set_runtime_closure_env(
const QoreClosureBase* current);
579typedef std::vector<ClosureVarValue*> cvv_vec_t;
580DLLLOCAL cvv_vec_t* thread_get_all_closure_vars();
582DLLLOCAL
void thread_push_frame_boundary();
583DLLLOCAL
void thread_pop_frame_boundary();
587DLLLOCAL
int thread_set_local_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
589DLLLOCAL
int thread_set_closure_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
591DLLLOCAL
int get_implicit_element();
592DLLLOCAL
int save_implicit_element(
int n_element);
594DLLLOCAL VNode* update_get_vstack(VNode* vn);
595DLLLOCAL
void save_global_vnode(VNode* vn);
596DLLLOCAL VNode* get_global_vnode();
598class QoreContainerHelper {
607 if (!thread_push_container(n_n)) {
621 DLLLOCAL ~QoreContainerHelper() {
623 thread_pop_container(n);
625 DLLLOCAL
operator bool ()
const {
632DLLLOCAL LocalVarValue* thread_find_lvar(
const char*
id);
635DLLLOCAL
QoreObject* runtime_get_stack_object();
637DLLLOCAL
const qore_class_private* runtime_get_class();
638DLLLOCAL
void runtime_get_object_and_class(
QoreObject*& obj,
const qore_class_private*& qc);
640DLLLOCAL
bool runtime_in_object_method(
const char* name,
const QoreObject* o);
642class CodeContextHelperBase {
644 const char* old_code;
646 const qore_class_private* old_class;
654 DLLLOCAL CodeContextHelperBase(
const char* code,
QoreObject* obj,
const qore_class_private* c,
656 DLLLOCAL ~CodeContextHelperBase();
659class ObjectSubstitutionHelper {
662 const qore_class_private* old_class;
665 DLLLOCAL ObjectSubstitutionHelper(
QoreObject* obj,
const qore_class_private* c);
666 DLLLOCAL ~ObjectSubstitutionHelper();
669class OptionalClassObjSubstitutionHelper {
671 DLLLOCAL OptionalClassObjSubstitutionHelper(
const qore_class_private* qc);
672 DLLLOCAL ~OptionalClassObjSubstitutionHelper();
676 const qore_class_private* old_class;
680class ClassOnlySubstitutionHelper {
682 DLLLOCAL ClassOnlySubstitutionHelper(
const qore_class_private* qc);
683 DLLLOCAL ~ClassOnlySubstitutionHelper();
686 const qore_class_private* old_class;
689class OptionalClassOnlySubstitutionHelper {
691 DLLLOCAL OptionalClassOnlySubstitutionHelper(
const qore_class_private* qc);
692 DLLLOCAL ~OptionalClassOnlySubstitutionHelper();
695 const qore_class_private* old_class;
699class OptionalObjectOnlySubstitutionHelper {
701 DLLLOCAL OptionalObjectOnlySubstitutionHelper() : subst(false) {
707 DLLLOCAL OptionalObjectOnlySubstitutionHelper(
QoreObject* obj);
709 DLLLOCAL ~OptionalObjectOnlySubstitutionHelper();
713 DLLLOCAL
operator bool()
const {
722class ThreadSafeLocalVarRuntimeEnvironmentHelper {
724 const QoreClosureBase* prev;
727 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironmentHelper(
const QoreClosureBase* current);
728 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironmentHelper();
731typedef std::map<const LocalVar*, ClosureVarValue*> cvar_map_t;
732typedef std::set<ClosureVarValue*> cvv_set_t;
734class ThreadSafeLocalVarRuntimeEnvironment {
740 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironment(
const lvar_set_t* vlist);
741 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironment();
742 DLLLOCAL ClosureVarValue* find(
const LocalVar*
id)
const;
743 DLLLOCAL
bool hasVar(ClosureVarValue* cvv)
const;
746 DLLLOCAL
bool empty() {
750 DLLLOCAL
const cvar_map_t& getMap()
const {
755hashdecl ThreadLocalProgramData;
757class ProgramThreadCountContextHelper {
759 DLLLOCAL ProgramThreadCountContextHelper() =
default;
761 DLLLOCAL ~ProgramThreadCountContextHelper();
765 DLLLOCAL
static ThreadLocalProgramData* getContextFrame(
int& frame,
ExceptionSink* xsink);
767 DLLLOCAL
bool isFirstThreadLocalProgramData(
const ThreadLocalProgramData* tlpd)
const;
771 ThreadLocalProgramData* old_tlpd =
nullptr;
772 ProgramThreadCountContextHelper* old_ctx =
nullptr;
774 int save_frameCount = 0;
775 int old_frameCount = 0;
776 bool restore =
false;
777 bool init_tlpd =
false;
780class ProgramRuntimeParseContextHelper {
787 DLLLOCAL ~ProgramRuntimeParseContextHelper();
791class ProgramRuntimeParseCommitContextHelper {
794 ThreadLocalProgramData* old_tlpd;
799 DLLLOCAL ~ProgramRuntimeParseCommitContextHelper();
802class ProgramRuntimeParseAccessHelper {
805 DLLLOCAL ~ProgramRuntimeParseAccessHelper();
812class RuntimeReferenceHelperBase {
814 DLLLOCAL RuntimeReferenceHelperBase(
const lvalue_ref& r,
ExceptionSink* n_xsink)
815 : ref(&r), pch(n_xsink, r.pgm, true), osh(r.self, r.cls) {
818 if (thread_ref_set(&r)) {
820 n_xsink->
raiseException(
"CIRCULAR-REFERENCE-ERROR",
"a circular lvalue reference was detected");
825 DLLLOCAL ~RuntimeReferenceHelperBase() {
827 thread_ref_remove(ref);
830 DLLLOCAL
operator bool()
const {
835 const lvalue_ref* ref;
836 ProgramThreadCountContextHelper pch;
837 ObjectSubstitutionHelper osh;
841class RuntimeReferenceHelper :
public RuntimeReferenceHelperBase {
844 : RuntimeReferenceHelperBase(*lvalue_ref::get(&r), n_xsink) {
847 DLLLOCAL RuntimeReferenceHelper(
const lvalue_ref& r,
ExceptionSink* n_xsink)
848 : RuntimeReferenceHelperBase(r, n_xsink) {
852class ArgvContextHelper {
856 DLLLOCAL ~ArgvContextHelper();
863class SingleArgvContextHelper {
868 DLLLOCAL ~SingleArgvContextHelper();
875class ImplicitElementHelper {
877 DLLLOCAL ImplicitElementHelper(
int n_element) : element(save_implicit_element(n_element)) {
879 DLLLOCAL ~ImplicitElementHelper() {
880 save_implicit_element(element);
887class CodeContextHelper :
public CodeContextHelperBase {
890 const qore_class_private* cls =
nullptr,
bool ref_obj =
true) :
891 CodeContextHelperBase(c, obj, cls, xs, ref_obj) {
895DLLLOCAL
void init_qore_threads();
897DLLLOCAL
void delete_qore_threads();
902#if defined(HAVE_PTHREAD_GET_STACKSIZE_NP) || (defined(QORE_HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE))
903#define QORE_HAVE_GET_STACK_SIZE
906#if defined(QORE_HAVE_PTHREAD_SETNAME_NP_1) || defined(QORE_HAVE_PTHREAD_SETNAME_NP_2) || defined(QORE_HAVE_PTHREAD_SETNAME_NP_3) || defined(QORE_HAVE_PTHREAD_SET_NAME_NP)
907#if defined(HAVE_PTHREAD_GET_NAME_NP) || defined(HAVE_PTHREAD_GETNAME_NP)
908#define QORE_HAVE_THREAD_NAME
912class QorePThreadAttr {
917 DLLLOCAL QorePThreadAttr() {
918 pthread_attr_init(&attr);
919 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
922 DLLLOCAL ~QorePThreadAttr() {
924 pthread_attr_destroy(&attr);
928#ifdef HAVE_PTHREAD_ATTR_GETSTACK
929 DLLLOCAL
void getstack(
void*& ptr,
size_t& ssize) {
930 pthread_attr_getstack(&attr, &ptr, &ssize);
934 DLLLOCAL
size_t getstacksize()
const {
936 pthread_attr_getstacksize(&attr, &ssize);
940 DLLLOCAL
int setstacksize(
size_t ssize) {
941 return pthread_attr_setstacksize(&attr, ssize);
944 DLLLOCAL pthread_attr_t* get_ptr() {
948#ifdef QORE_HAVE_GET_STACK_SIZE
949 DLLLOCAL
static size_t getCurrentThreadStackSize() {
950#ifdef HAVE_PTHREAD_GET_STACKSIZE_NP
951 return pthread_get_stacksize_np(pthread_self());
954 if (pthread_getattr_np(pthread_self(), &attr)) {
957 ON_BLOCK_EXIT(pthread_attr_destroy, &attr);
959 if (pthread_attr_getstacksize(&attr, &size)) {
968DLLLOCAL
extern QorePThreadAttr ta_default;
970#ifdef QORE_MANAGE_STACK
974class ParseCodeInfoHelper {
976 const char* parse_code;
977 const QoreTypeInfo* returnTypeInfo;
980 DLLLOCAL ParseCodeInfoHelper(
const char* n_parse_code,
const QoreTypeInfo* n_returnTypeInfo) {
981 parseSetCodeInfo(n_parse_code, n_returnTypeInfo, parse_code, returnTypeInfo);
984 DLLLOCAL ~ParseCodeInfoHelper() {
985 parseRestoreCodeInfo(parse_code, returnTypeInfo);
989class NamespaceParseContextHelper {
995 DLLLOCAL NamespaceParseContextHelper(qore_ns_private* n_ns) {
996 thread_set_ns(n_ns, ns);
997 restore = (ns != n_ns);
1000 DLLLOCAL ~NamespaceParseContextHelper() {
1007class OptionalNamespaceParseContextHelper {
1009 qore_ns_private* ns;
1013 DLLLOCAL OptionalNamespaceParseContextHelper(qore_ns_private* n_ns) {
1015 thread_set_ns(n_ns, ns);
1016 restore = (ns != n_ns);
1022 DLLLOCAL ~OptionalNamespaceParseContextHelper() {
1029class QoreParseClassHelper {
1031 const qore_class_private* cls;
1032 qore_ns_private* ns;
1036 DLLLOCAL QoreParseClassHelper(
QoreClass* new_cls, qore_ns_private* new_ns =
nullptr);
1038 DLLLOCAL ~QoreParseClassHelper();
1046 typedef std::set<QoreProgram*> pgm_set_t;
1054 DLLLOCAL
void ref() {
1058 DLLLOCAL ~ThreadProgramData() {
1059 assert(pgm_set.empty());
1063 DLLLOCAL ThreadProgramData(ThreadData* n_td) : td(n_td) {
1067 DLLLOCAL
bool saveProgram(
bool runtime,
ExceptionSink* xsink);
1070 DLLLOCAL
void deref() {
1074 DLLLOCAL
int gettid();
1077class ThreadFrameBoundaryHelper {
1079 DLLLOCAL ThreadFrameBoundaryHelper(
bool doit) : doit(doit) {
1082 thread_push_frame_boundary();
1086 DLLLOCAL ~ThreadFrameBoundaryHelper() {
1089 thread_pop_frame_boundary();
1097DLLLOCAL
extern pthread_mutexattr_t ma_recursive;
1100#ifdef QORE_HAVE_THREAD_NAME
1101DLLLOCAL
void q_set_thread_name(
const char* name);
1102DLLLOCAL
void q_get_thread_name(
QoreString& str);
1106DLLLOCAL
void checkpoint_stack_pos(
const char*);
The base class for all value and parse types in Qore expression trees.
Definition AbstractQoreNode.h:57
DLLLOCAL qore_type_t getType() const
returns the data type
Definition AbstractQoreNode.h:175
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition ExceptionSink.h:50
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
defines a Qore-language class
Definition QoreClass.h:310
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition QoreHashNode.h:51
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition QoreListNode.h:52
contains constants, classes, and subnamespaces in QoreProgram objects
Definition QoreNamespace.h:65
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition QoreObject.h:61
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition QoreProgram.h:128
provides a simple POSIX-threads-based read-write lock
Definition QoreRWLock.h:47
Provides atomic reference counting to Qore objects.
Definition QoreReferenceCounter.h:44
DLLEXPORT void ROreference() const
Atomically increments the reference count.
DLLEXPORT bool ROdereference() const
Atomically decrements the reference count.
Stack location element abstract class.
Definition ExceptionSink.h:426
virtual DLLLOCAL QoreProgram * getProgram() const =0
returns the QoreProgram container
virtual DLLLOCAL const AbstractStatement * getStatement() const =0
returns the statement for the call for internal Qore code
Qore's string type supported by the QoreEncoding class.
Definition QoreString.h:93
Qore's string value type, reference counted, dynamically-allocated only.
Definition QoreStringNode.h:50
provides a mutually-exclusive thread lock
Definition QoreThreadLock.h:49
parse type: reference to a lvalue expression
Definition ReferenceNode.h:45
the root namespace of a QoreProgram object
Definition QoreNamespace.h:397
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition common.h:76
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition common.h:266
const qore_type_t NT_LIST
type value for QoreListNode
Definition node_types.h:50
const qore_type_t NT_HASH
type value for QoreHashNode
Definition node_types.h:51
const qore_type_t NT_NOTHING
type value for QoreNothingNode
Definition node_types.h:42
const qore_type_t NT_OBJECT
type value for QoreObject
Definition node_types.h:52
#define QORE_NUM_TYPES
number of types implemented in the Qore library
Definition node_types.h:94
The main value class in Qore, designed to be passed by value.
Definition QoreValue.h:279
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values