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
int purge_thread_resources_to_mark(
ExceptionSink* xsink);
225DLLLOCAL
void mark_thread_resources();
226DLLLOCAL
void beginParsing(
const char* file,
void* ps = NULL,
const char* src =
nullptr,
int offset = 0);
227DLLLOCAL
void* endParsing();
228DLLLOCAL Context* get_context_stack();
229DLLLOCAL
void update_context_stack(Context* cstack);
233 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm);
235 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm,
const QoreProgramLocation*& old_runtime_loc);
237DLLLOCAL
void update_runtime_stack_location(
const QoreStackLocation* stack_loc,
const QoreProgramLocation* runtime_loc);
239DLLLOCAL
const QoreProgramLocation* get_runtime_location();
240DLLLOCAL
int swap_runtime_statement_location(
ExceptionSink* xsink,
const AbstractStatement* stmt,
241 const QoreProgramLocation* loc,
int64 po,
const AbstractStatement*& old_stmt,
242 const QoreProgramLocation*& old_loc,
int64& old_po);
243DLLLOCAL
void swap_runtime_location(
const QoreProgramLocation*loc,
const AbstractStatement*& old_stmt,
244 const QoreProgramLocation*& old_loc);
245DLLLOCAL
void update_runtime_statement_location(
const AbstractStatement* stmt,
const QoreProgramLocation* loc,
int64 po);
246DLLLOCAL
void update_runtime_statement_location(
const AbstractStatement* stmt,
const QoreProgramLocation* loc);
248DLLLOCAL
void set_parse_file_info(QoreProgramLocation& loc);
249DLLLOCAL
const char* get_parse_code();
251DLLLOCAL
const AbstractStatement* get_runtime_statement();
253DLLLOCAL
const QoreTypeInfo* parse_set_implicit_arg_type_info(
const QoreTypeInfo* ti);
254DLLLOCAL
const QoreTypeInfo* parse_get_implicit_arg_type_info();
256DLLLOCAL
int64 parse_get_parse_options();
257DLLLOCAL
int64 runtime_get_parse_options();
259DLLLOCAL
bool parse_check_parse_option(
int64 o);
260DLLLOCAL
bool runtime_check_parse_option(
int64 o);
263DLLLOCAL
void updateCVarStack(CVNode* ncvs);
264DLLLOCAL CVNode* getCVarStack();
265DLLLOCAL
void updateVStack(VNode* nvs);
266DLLLOCAL VNode* getVStack();
270DLLLOCAL qore_class_private* parse_get_class_priv();
271DLLLOCAL
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);
272DLLLOCAL
void thread_set_class_and_ns(
const qore_class_private* new_cls, qore_ns_private* new_ns);
273DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns, qore_ns_private*& old_ns);
274DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns);
275DLLLOCAL qore_ns_private* parse_get_ns();
277DLLLOCAL
void substituteObjectIfEqual(
QoreObject* o);
280DLLLOCAL QoreException* catch_swap_exception(QoreException* e);
281DLLLOCAL QoreException* catch_get_exception();
283DLLLOCAL VLock* getVLock();
285DLLLOCAL
void delete_thread_local_data();
286DLLLOCAL
void parse_cond_push(
bool mark =
false);
287DLLLOCAL
bool parse_cond_else();
288DLLLOCAL
bool parse_cond_pop(
const QoreProgramLocation* loc);
289DLLLOCAL
bool parse_cond_test(
const QoreProgramLocation* loc);
290DLLLOCAL
void push_parse_options();
291DLLLOCAL
void parse_try_module_inc();
292DLLLOCAL
bool parse_try_module_dec(
const QoreProgramLocation* loc);
293DLLLOCAL
unsigned parse_try_module_get();
294DLLLOCAL
void parse_try_module_set(
unsigned c);
296DLLLOCAL
void parse_push_name(
const char* name);
297DLLLOCAL std::string parse_pop_name(std::string& path);
299DLLLOCAL
void parse_push_ns_name(
const char* name);
300DLLLOCAL std::string parse_pop_ns_name(std::string& path);
302DLLLOCAL std::string get_ns_path(
const char* name);
304DLLLOCAL
void set_module_context(QoreModuleContext* qmc);
305DLLLOCAL QoreModuleContext* get_module_context();
306DLLLOCAL QoreModuleDefContext* set_module_def_context(QoreModuleDefContext* qmd);
307DLLLOCAL QoreModuleDefContext* get_module_def_context();
308DLLLOCAL
void parse_set_module_def_context_name(
const char* name);
309DLLLOCAL
const char* set_module_context_name(
const char* n);
310DLLLOCAL
const char* get_module_context_name();
312DLLLOCAL
void parse_set_try_reexport(
bool tr);
313DLLLOCAL
bool parse_get_try_reexport();
315DLLLOCAL
void set_thread_tz(
const AbstractQoreZoneInfo* tz);
316DLLLOCAL
const AbstractQoreZoneInfo* get_thread_tz(
bool& set);
317DLLLOCAL
void clear_thread_tz();
319DLLLOCAL ThreadProgramData* get_thread_program_data();
320DLLLOCAL ThreadLocalProgramData* get_thread_local_program_data();
322DLLLOCAL
int thread_ref_set(
const lvalue_ref* r);
323DLLLOCAL
void thread_ref_remove(
const lvalue_ref* r);
326DLLLOCAL
void new_argv_ref();
329DLLLOCAL
void inc_argv_ref();
332DLLLOCAL
void push_ignore_numeric_argv_ref();
335DLLLOCAL
void pop_ignore_numeric_argv_ref();
338DLLLOCAL
void inc_numeric_argv_ref();
341DLLLOCAL
int get_pop_argv_ref();
344DLLLOCAL
void clear_argv_ref();
346DLLLOCAL
int set_constant(ConstantEntry* ce);
347DLLLOCAL
void remove_constant(ConstantEntry* ce);
349DLLLOCAL QoreAbstractModule* set_reexport(QoreAbstractModule* m,
bool current_reexport,
bool& old_reexport);
350DLLLOCAL
void set_reexport(QoreAbstractModule* m,
bool reexport);
352DLLLOCAL
void parseSetCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo,
const char*& old_code,
const QoreTypeInfo*& old_returnTypeInfo);
353DLLLOCAL
void parseRestoreCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo);
355DLLLOCAL
const QoreTypeInfo* saveReturnTypeInfo(
const QoreTypeInfo* returnTypeInfo);
356DLLLOCAL
const QoreTypeInfo* getReturnTypeInfo();
358DLLLOCAL
const QoreTypeInfo* parse_get_return_type_info();
361DLLLOCAL
void set_program_call_context(
QoreProgram* new_pgm);
364class LVarStackBreakHelper {
366 DLLLOCAL LVarStackBreakHelper();
367 DLLLOCAL ~LVarStackBreakHelper();
373class ProgramCallContextHelper {
375 DLLLOCAL ProgramCallContextHelper(
QoreProgram* new_pgm);
376 DLLLOCAL ~ProgramCallContextHelper();
382class ModuleReExportHelper {
384 QoreAbstractModule* m;
388 DLLLOCAL ModuleReExportHelper(QoreAbstractModule* mi,
bool reexp);
389 DLLLOCAL ~ModuleReExportHelper();
392class QoreParseCountContextHelper {
397 DLLLOCAL QoreParseCountContextHelper() : count(parse_try_module_get()) {
398 parse_try_module_set(0);
401 DLLLOCAL ~QoreParseCountContextHelper() {
402 parse_try_module_set(count);
406class QoreProgramStackLocationHelper {
408 DLLLOCAL QoreProgramStackLocationHelper(
QoreStackLocation* stack_loc,
const AbstractStatement*& current_stmt,
410 stack_loc(update_get_runtime_stack_location(stack_loc, current_stmt, current_pgm)) {
413 DLLLOCAL ~QoreProgramStackLocationHelper() {
414 update_runtime_stack_location(stack_loc);
421class QoreInternalCallStackLocationHelperBase :
public QoreStackLocation,
public QoreProgramStackLocationHelper {
423 DLLLOCAL QoreInternalCallStackLocationHelperBase() : QoreProgramStackLocationHelper(this, stmt, pgm) {
430 DLLLOCAL
virtual const AbstractStatement*
getStatement()
const {
435 const AbstractStatement* stmt;
439class QoreInternalCallStackLocationHelper :
public QoreInternalCallStackLocationHelperBase {
441 DLLLOCAL QoreInternalCallStackLocationHelper(
const QoreProgramLocation& loc,
const std::string& call,
442 qore_call_t call_type) : loc(loc), call(call), call_type(call_type) {
446 DLLLOCAL
virtual const QoreProgramLocation& getLocation()
const {
451 DLLLOCAL
virtual const std::string& getCallName()
const {
455 DLLLOCAL
virtual qore_call_t getCallType()
const {
460 const QoreProgramLocation& loc;
461 const std::string call;
462 qore_call_t call_type;
465class QoreProgramLocationHelper {
467 DLLLOCAL QoreProgramLocationHelper(
ExceptionSink* xsink,
const QoreProgramLocation* loc,
468 const AbstractStatement* stat,
int64 parse_options) : has_po(true) {
469 swap_runtime_statement_location(xsink, stat, loc, parse_options, statement, this->loc,
470 this->parse_options);
473 DLLLOCAL QoreProgramLocationHelper(
const QoreProgramLocation* loc) : has_po(false) {
474 swap_runtime_location(loc, statement, this->loc);
477 DLLLOCAL ~QoreProgramLocationHelper() {
479 update_runtime_statement_location(statement, loc, parse_options);
481 update_runtime_statement_location(statement, loc);
486 const QoreProgramLocation* loc;
487 const AbstractStatement* statement;
492class QoreProgramOptionalLocationHelper {
494 DLLLOCAL QoreProgramOptionalLocationHelper(
const QoreProgramLocation* loc) : restore((bool)loc) {
496 swap_runtime_location(loc, statement, this->loc);
500 DLLLOCAL ~QoreProgramOptionalLocationHelper() {
502 update_runtime_statement_location(statement, loc);
507 const QoreProgramLocation* loc;
508 const AbstractStatement* statement;
513class CurrentProgramRuntimeParseContextHelper {
516 DLLEXPORT CurrentProgramRuntimeParseContextHelper();
518 DLLEXPORT ~CurrentProgramRuntimeParseContextHelper();
522 CurrentProgramRuntimeParseContextHelper(
const CurrentProgramRuntimeParseContextHelper&) =
delete;
523 void*
operator new(size_t) =
delete;
527class ParseImplicitArgTypeHelper {
529 DLLLOCAL ParseImplicitArgTypeHelper(
const QoreTypeInfo* ti) : ati(parse_set_implicit_arg_type_info(ti)) {
532 DLLLOCAL ~ParseImplicitArgTypeHelper() {
533 parse_set_implicit_arg_type_info(ati);
537 const QoreTypeInfo* ati;
541DLLLOCAL
int get_thread_entry(
bool reuse_last =
false);
543DLLLOCAL
int get_signal_thread_entry();
544DLLLOCAL
void deregister_signal_thread();
545DLLLOCAL
void register_thread(
int tid, pthread_t ptid,
QoreProgram* pgm,
bool foreign =
false);
546DLLLOCAL
void deregister_thread(
int tid);
547DLLLOCAL
void delete_signal_thread();
554DLLLOCAL
void pushBlock(block_list_t::iterator i);
556DLLLOCAL block_list_t::iterator popBlock();
558DLLLOCAL
void advance_on_block_exit();
560DLLLOCAL LocalVarValue* thread_instantiate_lvar();
561DLLLOCAL
void thread_uninstantiate_lvar(
ExceptionSink* xsink);
562DLLLOCAL
void thread_uninstantiate_self();
564DLLLOCAL
void thread_set_closure_parse_env(ClosureParseEnvironment* cenv);
565DLLLOCAL ClosureParseEnvironment* thread_get_closure_parse_env();
567DLLLOCAL ClosureVarValue* thread_instantiate_closure_var(
const char*
id,
const QoreTypeInfo* typeInfo,
QoreValue& nval,
bool assign);
568DLLLOCAL
void thread_instantiate_closure_var(ClosureVarValue* cvar);
569DLLLOCAL
void thread_uninstantiate_closure_var(
ExceptionSink* xsink);
570DLLLOCAL ClosureVarValue* thread_find_closure_var(
const char*
id);
572DLLLOCAL ClosureVarValue* thread_get_runtime_closure_var(
const LocalVar*
id);
573DLLLOCAL
const QoreClosureBase* thread_set_runtime_closure_env(
const QoreClosureBase* current);
575typedef std::vector<ClosureVarValue*> cvv_vec_t;
576DLLLOCAL cvv_vec_t* thread_get_all_closure_vars();
578DLLLOCAL
void thread_push_frame_boundary();
579DLLLOCAL
void thread_pop_frame_boundary();
583DLLLOCAL
int thread_set_local_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
585DLLLOCAL
int thread_set_closure_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
587DLLLOCAL
int get_implicit_element();
588DLLLOCAL
int save_implicit_element(
int n_element);
590DLLLOCAL VNode* update_get_vstack(VNode* vn);
591DLLLOCAL
void save_global_vnode(VNode* vn);
592DLLLOCAL VNode* get_global_vnode();
594class QoreContainerHelper {
603 if (!thread_push_container(n_n)) {
617 DLLLOCAL ~QoreContainerHelper() {
619 thread_pop_container(n);
621 DLLLOCAL
operator bool ()
const {
628DLLLOCAL LocalVarValue* thread_find_lvar(
const char*
id);
631DLLLOCAL
QoreObject* runtime_get_stack_object();
633DLLLOCAL
const qore_class_private* runtime_get_class();
634DLLLOCAL
void runtime_get_object_and_class(
QoreObject*& obj,
const qore_class_private*& qc);
636DLLLOCAL
bool runtime_in_object_method(
const char* name,
const QoreObject* o);
638class CodeContextHelperBase {
640 const char* old_code;
642 const qore_class_private* old_class;
650 DLLLOCAL CodeContextHelperBase(
const char* code,
QoreObject* obj,
const qore_class_private* c,
652 DLLLOCAL ~CodeContextHelperBase();
655class ObjectSubstitutionHelper {
658 const qore_class_private* old_class;
661 DLLLOCAL ObjectSubstitutionHelper(
QoreObject* obj,
const qore_class_private* c);
662 DLLLOCAL ~ObjectSubstitutionHelper();
665class OptionalClassObjSubstitutionHelper {
667 DLLLOCAL OptionalClassObjSubstitutionHelper(
const qore_class_private* qc);
668 DLLLOCAL ~OptionalClassObjSubstitutionHelper();
672 const qore_class_private* old_class;
676class ClassOnlySubstitutionHelper {
678 DLLLOCAL ClassOnlySubstitutionHelper(
const qore_class_private* qc);
679 DLLLOCAL ~ClassOnlySubstitutionHelper();
682 const qore_class_private* old_class;
685class OptionalClassOnlySubstitutionHelper {
687 DLLLOCAL OptionalClassOnlySubstitutionHelper(
const qore_class_private* qc);
688 DLLLOCAL ~OptionalClassOnlySubstitutionHelper();
691 const qore_class_private* old_class;
695class OptionalObjectOnlySubstitutionHelper {
697 DLLLOCAL OptionalObjectOnlySubstitutionHelper(
QoreObject* obj);
698 DLLLOCAL ~OptionalObjectOnlySubstitutionHelper();
705class ThreadSafeLocalVarRuntimeEnvironmentHelper {
707 const QoreClosureBase* prev;
710 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironmentHelper(
const QoreClosureBase* current);
711 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironmentHelper();
714typedef std::map<const LocalVar*, ClosureVarValue*> cvar_map_t;
715typedef std::set<ClosureVarValue*> cvv_set_t;
717class ThreadSafeLocalVarRuntimeEnvironment {
723 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironment(
const lvar_set_t* vlist);
724 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironment();
725 DLLLOCAL ClosureVarValue* find(
const LocalVar*
id)
const;
726 DLLLOCAL
bool hasVar(ClosureVarValue* cvv)
const;
729 DLLLOCAL
bool empty() {
733 DLLLOCAL
const cvar_map_t& getMap()
const {
738hashdecl ThreadLocalProgramData;
740class ProgramThreadCountContextHelper {
742 DLLLOCAL ProgramThreadCountContextHelper() =
default;
744 DLLLOCAL ~ProgramThreadCountContextHelper();
748 DLLLOCAL
static ThreadLocalProgramData* getContextFrame(
int& frame,
ExceptionSink* xsink);
750 DLLLOCAL
bool isFirstThreadLocalProgramData(
const ThreadLocalProgramData* tlpd)
const;
754 ThreadLocalProgramData* old_tlpd =
nullptr;
755 ProgramThreadCountContextHelper* old_ctx =
nullptr;
757 int save_frameCount = 0;
758 int old_frameCount = 0;
759 bool restore =
false;
760 bool init_tlpd =
false;
763class ProgramRuntimeParseContextHelper {
770 DLLLOCAL ~ProgramRuntimeParseContextHelper();
774class ProgramRuntimeParseCommitContextHelper {
777 ThreadLocalProgramData* old_tlpd;
782 DLLLOCAL ~ProgramRuntimeParseCommitContextHelper();
785class ProgramRuntimeParseAccessHelper {
788 DLLLOCAL ~ProgramRuntimeParseAccessHelper();
795class RuntimeReferenceHelperBase {
797 DLLLOCAL RuntimeReferenceHelperBase(
const lvalue_ref& r,
ExceptionSink* n_xsink)
798 : ref(&r), pch(n_xsink, r.pgm, true), osh(r.self, r.cls) {
801 if (thread_ref_set(&r)) {
803 n_xsink->
raiseException(
"CIRCULAR-REFERENCE-ERROR",
"a circular lvalue reference was detected");
808 DLLLOCAL ~RuntimeReferenceHelperBase() {
810 thread_ref_remove(ref);
813 DLLLOCAL
operator bool()
const {
818 const lvalue_ref* ref;
819 ProgramThreadCountContextHelper pch;
820 ObjectSubstitutionHelper osh;
824class RuntimeReferenceHelper :
public RuntimeReferenceHelperBase {
827 : RuntimeReferenceHelperBase(*lvalue_ref::get(&r), n_xsink) {
830 DLLLOCAL RuntimeReferenceHelper(
const lvalue_ref& r,
ExceptionSink* n_xsink)
831 : RuntimeReferenceHelperBase(r, n_xsink) {
835class ArgvContextHelper {
839 DLLLOCAL ~ArgvContextHelper();
846class SingleArgvContextHelper {
851 DLLLOCAL ~SingleArgvContextHelper();
858class ImplicitElementHelper {
860 DLLLOCAL ImplicitElementHelper(
int n_element) : element(save_implicit_element(n_element)) {
862 DLLLOCAL ~ImplicitElementHelper() {
863 save_implicit_element(element);
870class CodeContextHelper :
public CodeContextHelperBase {
873 const qore_class_private* cls =
nullptr,
bool ref_obj =
true) :
874 CodeContextHelperBase(c, obj, cls, xs, ref_obj) {
878DLLLOCAL
void init_qore_threads();
880DLLLOCAL
void delete_qore_threads();
885#if defined(HAVE_PTHREAD_GET_STACKSIZE_NP) || (defined(QORE_HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE))
886#define QORE_HAVE_GET_STACK_SIZE
889#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)
890#if defined(HAVE_PTHREAD_GET_NAME_NP) || defined(HAVE_PTHREAD_GETNAME_NP)
891#define QORE_HAVE_THREAD_NAME
895class QorePThreadAttr {
900 DLLLOCAL QorePThreadAttr() {
901 pthread_attr_init(&attr);
902 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
905 DLLLOCAL ~QorePThreadAttr() {
907 pthread_attr_destroy(&attr);
911#ifdef HAVE_PTHREAD_ATTR_GETSTACK
912 DLLLOCAL
void getstack(
void*& ptr,
size_t& ssize) {
913 pthread_attr_getstack(&attr, &ptr, &ssize);
917 DLLLOCAL
size_t getstacksize()
const {
919 pthread_attr_getstacksize(&attr, &ssize);
923 DLLLOCAL
int setstacksize(
size_t ssize) {
924 return pthread_attr_setstacksize(&attr, ssize);
927 DLLLOCAL pthread_attr_t* get_ptr() {
931#ifdef QORE_HAVE_GET_STACK_SIZE
932 DLLLOCAL
static size_t getCurrentThreadStackSize() {
933#ifdef HAVE_PTHREAD_GET_STACKSIZE_NP
934 return pthread_get_stacksize_np(pthread_self());
937 if (pthread_getattr_np(pthread_self(), &attr)) {
940 ON_BLOCK_EXIT(pthread_attr_destroy, &attr);
942 if (pthread_attr_getstacksize(&attr, &size)) {
951DLLLOCAL
extern QorePThreadAttr ta_default;
953#ifdef QORE_MANAGE_STACK
957class ParseCodeInfoHelper {
959 const char* parse_code;
960 const QoreTypeInfo* returnTypeInfo;
963 DLLLOCAL ParseCodeInfoHelper(
const char* n_parse_code,
const QoreTypeInfo* n_returnTypeInfo) {
964 parseSetCodeInfo(n_parse_code, n_returnTypeInfo, parse_code, returnTypeInfo);
967 DLLLOCAL ~ParseCodeInfoHelper() {
968 parseRestoreCodeInfo(parse_code, returnTypeInfo);
972class NamespaceParseContextHelper {
978 DLLLOCAL NamespaceParseContextHelper(qore_ns_private* n_ns) {
979 thread_set_ns(n_ns, ns);
980 restore = (ns != n_ns);
983 DLLLOCAL ~NamespaceParseContextHelper() {
990class OptionalNamespaceParseContextHelper {
996 DLLLOCAL OptionalNamespaceParseContextHelper(qore_ns_private* n_ns) {
998 thread_set_ns(n_ns, ns);
999 restore = (ns != n_ns);
1005 DLLLOCAL ~OptionalNamespaceParseContextHelper() {
1012class QoreParseClassHelper {
1014 const qore_class_private* cls;
1015 qore_ns_private* ns;
1019 DLLLOCAL QoreParseClassHelper(
QoreClass* new_cls, qore_ns_private* new_ns =
nullptr);
1021 DLLLOCAL ~QoreParseClassHelper();
1029 typedef std::set<QoreProgram*> pgm_set_t;
1037 DLLLOCAL
void ref() {
1041 DLLLOCAL ~ThreadProgramData() {
1042 assert(pgm_set.empty());
1046 DLLLOCAL ThreadProgramData(ThreadData* n_td) : td(n_td) {
1050 DLLLOCAL
bool saveProgram(
bool runtime,
ExceptionSink* xsink);
1053 DLLLOCAL
void deref() {
1057 DLLLOCAL
int gettid();
1060class ThreadFrameBoundaryHelper {
1062 DLLLOCAL ThreadFrameBoundaryHelper(
bool doit) : doit(doit) {
1065 thread_push_frame_boundary();
1069 DLLLOCAL ~ThreadFrameBoundaryHelper() {
1072 thread_pop_frame_boundary();
1080DLLLOCAL
extern pthread_mutexattr_t ma_recursive;
1083#ifdef QORE_HAVE_THREAD_NAME
1084DLLLOCAL
void q_set_thread_name(
const char* name);
1085DLLLOCAL
void q_get_thread_name(
QoreString& str);
1089DLLLOCAL
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:257
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:423
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:70
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:260
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:92
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