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)
58 class ClosureParseEnvironment;
59 class QoreClosureBase;
60 hashdecl ClosureVarValue;
63 class qore_ns_private;
64 class qore_root_ns_private;
65 class qore_class_private;
66 class AbstractQoreFunctionVariant;
67 class AbstractQoreZoneInfo;
68 class ThreadProgramData;
69 hashdecl ThreadLocalProgramData;
70 class QoreAbstractModule;
73 DLLLOCAL
extern Operator* OP_BACKGROUND;
76 class AbstractQoreZoneInfo;
79 hashdecl ModuleContextNamespaceCommit {
80 qore_ns_private* parent;
83 DLLLOCAL ModuleContextNamespaceCommit(qore_ns_private* n_parent, qore_ns_private* n_nns) : parent(n_parent), nns(n_nns) {
87 typedef std::vector<ModuleContextNamespaceCommit> mcnl_t;
89 class ModuleContextNamespaceList :
public mcnl_t {
92 DLLLOCAL ModuleContextNamespaceList(
const ModuleContextNamespaceList&);
95 DLLLOCAL ModuleContextNamespaceList() {
98 DLLLOCAL ~ModuleContextNamespaceList() {
102 DLLLOCAL
void clear();
105 hashdecl ModuleContextFunctionCommit {
106 qore_ns_private* parent;
108 AbstractQoreFunctionVariant* v;
110 DLLLOCAL ModuleContextFunctionCommit(qore_ns_private* n_parent,
const char* n_name, AbstractQoreFunctionVariant* n_v) : parent(n_parent), name(n_name), v(n_v) {
114 typedef std::vector<ModuleContextFunctionCommit> mcfl_t;
116 class ModuleContextFunctionList :
public mcfl_t {
119 DLLLOCAL ModuleContextFunctionList(
const ModuleContextFunctionList&);
122 DLLLOCAL ModuleContextFunctionList() {
125 DLLLOCAL ~ModuleContextFunctionList() {
129 DLLLOCAL
void clear();
132 class QoreModuleContext {
134 ModuleContextNamespaceList mcnl;
135 ModuleContextFunctionList mcfl;
137 DLLLOCAL QoreModuleContext(
const char* n, qore_root_ns_private* n_rns,
ExceptionSink& xs);
139 DLLLOCAL ~QoreModuleContext() {
143 DLLLOCAL
void error(
const char* fmt, ...);
145 DLLLOCAL
bool hasError()
const {
149 DLLLOCAL
void commit();
151 DLLLOCAL
void rollback() {
156 DLLLOCAL qore_root_ns_private* getRootNS()
const {
160 DLLLOCAL
const char* getName()
const {
166 qore_root_ns_private* rns;
168 QoreModuleContext* parent;
172 class QoreModuleDefContext {
174 typedef std::set<std::string> strset_t;
175 typedef std::map<std::string, std::string> strmap_t;
180 const QoreProgramLocation* init_loc =
nullptr,
183 DLLLOCAL QoreModuleDefContext() {
186 DLLLOCAL ~QoreModuleDefContext() {
192 static strset_t vset;
197 DLLLOCAL
int set(
const QoreProgramLocation* loc,
const char* key,
QoreValue val);
199 DLLLOCAL
const char* get(
const char* str)
const {
200 strmap_t::const_iterator i = vmap.find(str);
201 return i == vmap.end() || i->second.empty() ? nullptr : i->second.c_str();
204 DLLLOCAL
int parseInit();
206 DLLLOCAL
bool hasInit()
const {
207 return init_c ? true :
false;
215 DLLLOCAL
int initClosure(
const QoreProgramLocation* loc,
QoreValue& c,
const char* n);
221 DLLLOCAL
int purge_thread_resources_to_mark(
ExceptionSink* xsink);
224 DLLLOCAL
void mark_thread_resources();
225 DLLLOCAL
void beginParsing(
const char* file,
void* ps = NULL,
const char* src =
nullptr,
int offset = 0);
226 DLLLOCAL
void* endParsing();
227 DLLLOCAL Context* get_context_stack();
228 DLLLOCAL
void update_context_stack(Context* cstack);
232 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm);
234 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm,
const QoreProgramLocation*& old_runtime_loc);
236 DLLLOCAL
void update_runtime_stack_location(
const QoreStackLocation* stack_loc,
const QoreProgramLocation* runtime_loc);
238 DLLLOCAL
const QoreProgramLocation* get_runtime_location();
239 DLLLOCAL
void update_get_runtime_statement_location(
const AbstractStatement* stmt,
240 const QoreProgramLocation* loc,
const AbstractStatement*& old_stmt,
const QoreProgramLocation*& old_loc);
241 DLLLOCAL
void update_runtime_statement_location(
const AbstractStatement* stmt,
const QoreProgramLocation* loc);
243 DLLLOCAL
void set_parse_file_info(QoreProgramLocation& loc);
244 DLLLOCAL
const char* get_parse_code();
246 DLLLOCAL
const AbstractStatement* get_runtime_statement();
248 DLLLOCAL
const QoreTypeInfo* parse_set_implicit_arg_type_info(
const QoreTypeInfo* ti);
249 DLLLOCAL
const QoreTypeInfo* parse_get_implicit_arg_type_info();
251 DLLLOCAL
int64 parse_get_parse_options();
252 DLLLOCAL
int64 runtime_get_parse_options();
254 DLLLOCAL
bool parse_check_parse_option(
int64 o);
255 DLLLOCAL
bool runtime_check_parse_option(
int64 o);
258 DLLLOCAL
void updateCVarStack(CVNode* ncvs);
259 DLLLOCAL CVNode* getCVarStack();
260 DLLLOCAL
void updateVStack(VNode* nvs);
261 DLLLOCAL VNode* getVStack();
265 DLLLOCAL qore_class_private* parse_get_class_priv();
266 DLLLOCAL
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);
267 DLLLOCAL
void thread_set_class_and_ns(
const qore_class_private* new_cls, qore_ns_private* new_ns);
268 DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns, qore_ns_private*& old_ns);
269 DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns);
270 DLLLOCAL qore_ns_private* parse_get_ns();
272 DLLLOCAL
void substituteObjectIfEqual(
QoreObject* o);
275 DLLLOCAL QoreException* catch_swap_exception(QoreException* e);
276 DLLLOCAL QoreException* catch_get_exception();
278 DLLLOCAL VLock* getVLock();
280 DLLLOCAL
void delete_thread_local_data();
281 DLLLOCAL
void parse_cond_push(
bool mark =
false);
282 DLLLOCAL
bool parse_cond_else();
283 DLLLOCAL
bool parse_cond_pop(
const QoreProgramLocation* loc);
284 DLLLOCAL
bool parse_cond_test(
const QoreProgramLocation* loc);
285 DLLLOCAL
void push_parse_options();
286 DLLLOCAL
void parse_try_module_inc();
287 DLLLOCAL
bool parse_try_module_dec(
const QoreProgramLocation* loc);
288 DLLLOCAL
unsigned parse_try_module_get();
289 DLLLOCAL
void parse_try_module_set(
unsigned c);
291 DLLLOCAL
void parse_push_name(
const char* name);
292 DLLLOCAL std::string parse_pop_name(std::string& path);
294 DLLLOCAL
void parse_push_ns_name(
const char* name);
295 DLLLOCAL std::string parse_pop_ns_name(std::string& path);
297 DLLLOCAL std::string get_ns_path(
const char* name);
299 DLLLOCAL
void set_module_context(QoreModuleContext* qmc);
300 DLLLOCAL QoreModuleContext* get_module_context();
301 DLLLOCAL QoreModuleDefContext* set_module_def_context(QoreModuleDefContext* qmd);
302 DLLLOCAL QoreModuleDefContext* get_module_def_context();
303 DLLLOCAL
void parse_set_module_def_context_name(
const char* name);
304 DLLLOCAL
const char* set_module_context_name(
const char* n);
305 DLLLOCAL
const char* get_module_context_name();
307 DLLLOCAL
void parse_set_try_reexport(
bool tr);
308 DLLLOCAL
bool parse_get_try_reexport();
310 DLLLOCAL
void set_thread_tz(
const AbstractQoreZoneInfo* tz);
311 DLLLOCAL
const AbstractQoreZoneInfo* get_thread_tz(
bool& set);
312 DLLLOCAL
void clear_thread_tz();
314 DLLLOCAL ThreadProgramData* get_thread_program_data();
315 DLLLOCAL ThreadLocalProgramData* get_thread_local_program_data();
317 DLLLOCAL
int thread_ref_set(
const lvalue_ref* r);
318 DLLLOCAL
void thread_ref_remove(
const lvalue_ref* r);
321 DLLLOCAL
void new_argv_ref();
324 DLLLOCAL
void inc_argv_ref();
327 DLLLOCAL
void push_ignore_numeric_argv_ref();
330 DLLLOCAL
void pop_ignore_numeric_argv_ref();
333 DLLLOCAL
void inc_numeric_argv_ref();
336 DLLLOCAL
int get_pop_argv_ref();
339 DLLLOCAL
void clear_argv_ref();
341 DLLLOCAL
int set_constant(ConstantEntry* ce);
342 DLLLOCAL
void remove_constant(ConstantEntry* ce);
344 DLLLOCAL QoreAbstractModule* set_reexport(QoreAbstractModule* m,
bool current_reexport,
bool& old_reexport);
345 DLLLOCAL
void set_reexport(QoreAbstractModule* m,
bool reexport);
347 DLLLOCAL
void parseSetCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo,
const char*& old_code,
const QoreTypeInfo*& old_returnTypeInfo);
348 DLLLOCAL
void parseRestoreCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo);
350 DLLLOCAL
const QoreTypeInfo* saveReturnTypeInfo(
const QoreTypeInfo* returnTypeInfo);
351 DLLLOCAL
const QoreTypeInfo* getReturnTypeInfo();
353 DLLLOCAL
const QoreTypeInfo* parse_get_return_type_info();
356 DLLLOCAL
void set_program_call_context(
QoreProgram* new_pgm);
359 class LVarStackBreakHelper {
361 DLLLOCAL LVarStackBreakHelper();
362 DLLLOCAL ~LVarStackBreakHelper();
368 class ProgramCallContextHelper {
370 DLLLOCAL ProgramCallContextHelper(
QoreProgram* new_pgm);
371 DLLLOCAL ~ProgramCallContextHelper();
377 class ModuleReExportHelper {
379 QoreAbstractModule* m;
383 DLLLOCAL ModuleReExportHelper(QoreAbstractModule* mi,
bool reexp);
384 DLLLOCAL ~ModuleReExportHelper();
387 class QoreParseCountContextHelper {
392 DLLLOCAL QoreParseCountContextHelper() : count(parse_try_module_get()) {
393 parse_try_module_set(0);
396 DLLLOCAL ~QoreParseCountContextHelper() {
397 parse_try_module_set(count);
401 class QoreProgramStackLocationHelper {
403 DLLLOCAL QoreProgramStackLocationHelper(
QoreStackLocation* stack_loc,
const AbstractStatement*& current_stmt,
405 stack_loc(update_get_runtime_stack_location(stack_loc, current_stmt, current_pgm)) {
408 DLLLOCAL ~QoreProgramStackLocationHelper() {
409 update_runtime_stack_location(stack_loc);
416 class QoreInternalCallStackLocationHelperBase :
public QoreStackLocation,
public QoreProgramStackLocationHelper {
418 DLLLOCAL QoreInternalCallStackLocationHelperBase() : QoreProgramStackLocationHelper(this, stmt, pgm) {
425 DLLLOCAL
virtual const AbstractStatement*
getStatement()
const {
430 const AbstractStatement* stmt;
434 class QoreInternalCallStackLocationHelper :
public QoreInternalCallStackLocationHelperBase {
436 DLLLOCAL QoreInternalCallStackLocationHelper(
const QoreProgramLocation& loc,
const std::string& call,
437 qore_call_t call_type) : loc(loc), call(call), call_type(call_type) {
441 DLLLOCAL
virtual const QoreProgramLocation& getLocation()
const {
446 DLLLOCAL
virtual const std::string& getCallName()
const {
450 DLLLOCAL
virtual qore_call_t getCallType()
const {
455 const QoreProgramLocation& loc;
456 const std::string call;
457 qore_call_t call_type;
460 class QoreProgramLocationHelper {
462 DLLLOCAL QoreProgramLocationHelper(
const QoreProgramLocation* n_loc,
const AbstractStatement* n_stat =
nullptr) {
463 update_get_runtime_statement_location(n_stat, n_loc, statement, loc);
466 DLLLOCAL ~QoreProgramLocationHelper() {
467 update_runtime_statement_location(statement, loc);
471 const QoreProgramLocation* loc;
472 const AbstractStatement* statement;
475 class QoreProgramOptionalLocationHelper {
477 DLLLOCAL QoreProgramOptionalLocationHelper(
const QoreProgramLocation* n_loc,
const AbstractStatement* n_stat =
nullptr) : restore((bool)n_loc) {
479 update_get_runtime_statement_location(n_stat, n_loc, statement, loc);
483 DLLLOCAL ~QoreProgramOptionalLocationHelper() {
485 update_runtime_statement_location(statement, loc);
490 const QoreProgramLocation* loc;
491 const AbstractStatement* statement;
496 class CurrentProgramRuntimeParseContextHelper {
499 DLLEXPORT CurrentProgramRuntimeParseContextHelper();
501 DLLEXPORT ~CurrentProgramRuntimeParseContextHelper();
505 CurrentProgramRuntimeParseContextHelper(
const CurrentProgramRuntimeParseContextHelper&) =
delete;
506 void*
operator new(size_t) =
delete;
510 class ParseImplicitArgTypeHelper {
512 DLLLOCAL ParseImplicitArgTypeHelper(
const QoreTypeInfo* ti) : ati(parse_set_implicit_arg_type_info(ti)) {
515 DLLLOCAL ~ParseImplicitArgTypeHelper() {
516 parse_set_implicit_arg_type_info(ati);
520 const QoreTypeInfo* ati;
524 DLLLOCAL
int get_thread_entry(
bool reuse_last =
false);
526 DLLLOCAL
int get_signal_thread_entry();
527 DLLLOCAL
void deregister_signal_thread();
528 DLLLOCAL
void register_thread(
int tid, pthread_t ptid,
QoreProgram* pgm,
bool foreign =
false);
529 DLLLOCAL
void deregister_thread(
int tid);
530 DLLLOCAL
void delete_signal_thread();
537 DLLLOCAL
void pushBlock(block_list_t::iterator i);
539 DLLLOCAL block_list_t::iterator popBlock();
541 DLLLOCAL
void advance_on_block_exit();
543 DLLLOCAL LocalVarValue* thread_instantiate_lvar();
544 DLLLOCAL
void thread_uninstantiate_lvar(
ExceptionSink* xsink);
545 DLLLOCAL
void thread_uninstantiate_self();
547 DLLLOCAL
void thread_set_closure_parse_env(ClosureParseEnvironment* cenv);
548 DLLLOCAL ClosureParseEnvironment* thread_get_closure_parse_env();
550 DLLLOCAL ClosureVarValue* thread_instantiate_closure_var(
const char*
id,
const QoreTypeInfo* typeInfo,
QoreValue& nval,
bool assign);
551 DLLLOCAL
void thread_instantiate_closure_var(ClosureVarValue* cvar);
552 DLLLOCAL
void thread_uninstantiate_closure_var(
ExceptionSink* xsink);
553 DLLLOCAL ClosureVarValue* thread_find_closure_var(
const char*
id);
555 DLLLOCAL ClosureVarValue* thread_get_runtime_closure_var(
const LocalVar*
id);
556 DLLLOCAL
const QoreClosureBase* thread_set_runtime_closure_env(
const QoreClosureBase* current);
558 typedef std::vector<ClosureVarValue*> cvv_vec_t;
559 DLLLOCAL cvv_vec_t* thread_get_all_closure_vars();
561 DLLLOCAL
void thread_push_frame_boundary();
562 DLLLOCAL
void thread_pop_frame_boundary();
566 DLLLOCAL
int thread_set_local_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
568 DLLLOCAL
int thread_set_closure_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
570 DLLLOCAL
int get_implicit_element();
571 DLLLOCAL
int save_implicit_element(
int n_element);
573 DLLLOCAL VNode* update_get_vstack(VNode* vn);
574 DLLLOCAL
void save_global_vnode(VNode* vn);
575 DLLLOCAL VNode* get_global_vnode();
577 class QoreContainerHelper {
586 if (!thread_push_container(n_n)) {
600 DLLLOCAL ~QoreContainerHelper() {
602 thread_pop_container(n);
604 DLLLOCAL
operator bool ()
const {
609 DLLLOCAL
const QoreListNode* thread_get_implicit_args();
611 DLLLOCAL LocalVarValue* thread_find_lvar(
const char*
id);
614 DLLLOCAL
QoreObject* runtime_get_stack_object();
616 DLLLOCAL
const qore_class_private* runtime_get_class();
617 DLLLOCAL
void runtime_get_object_and_class(
QoreObject*& obj,
const qore_class_private*& qc);
619 DLLLOCAL
bool runtime_in_object_method(
const char* name,
const QoreObject* o);
621 class CodeContextHelperBase {
623 const char* old_code;
625 const qore_class_private* old_class;
633 DLLLOCAL CodeContextHelperBase(
const char* code,
QoreObject* obj,
const qore_class_private* c,
ExceptionSink* xsink,
bool ref_obj =
true);
634 DLLLOCAL ~CodeContextHelperBase();
637 class ObjectSubstitutionHelper {
640 const qore_class_private* old_class;
643 DLLLOCAL ObjectSubstitutionHelper(
QoreObject* obj,
const qore_class_private* c);
644 DLLLOCAL ~ObjectSubstitutionHelper();
647 class OptionalClassObjSubstitutionHelper {
649 DLLLOCAL OptionalClassObjSubstitutionHelper(
const qore_class_private* qc);
650 DLLLOCAL ~OptionalClassObjSubstitutionHelper();
654 const qore_class_private* old_class;
658 class OptionalClassOnlySubstitutionHelper {
660 DLLLOCAL OptionalClassOnlySubstitutionHelper(
const qore_class_private* qc);
661 DLLLOCAL ~OptionalClassOnlySubstitutionHelper();
664 const qore_class_private* old_class;
668 class OptionalObjectOnlySubstitutionHelper {
670 DLLLOCAL OptionalObjectOnlySubstitutionHelper(
QoreObject* obj);
671 DLLLOCAL ~OptionalObjectOnlySubstitutionHelper();
678 class ThreadSafeLocalVarRuntimeEnvironmentHelper {
680 const QoreClosureBase* prev;
683 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironmentHelper(
const QoreClosureBase* current);
684 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironmentHelper();
687 typedef std::map<const LocalVar*, ClosureVarValue*> cvar_map_t;
688 typedef std::set<ClosureVarValue*> cvv_set_t;
690 class ThreadSafeLocalVarRuntimeEnvironment {
696 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironment(
const lvar_set_t* vlist);
697 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironment();
698 DLLLOCAL ClosureVarValue* find(
const LocalVar*
id)
const;
699 DLLLOCAL
bool hasVar(ClosureVarValue* cvv)
const;
702 DLLLOCAL
bool empty() {
706 DLLLOCAL
const cvar_map_t& getMap()
const {
711 hashdecl ThreadLocalProgramData;
713 class QoreProgramBlockParseOptionHelper {
715 DLLLOCAL QoreProgramBlockParseOptionHelper(
int64 n_po);
716 DLLLOCAL ~QoreProgramBlockParseOptionHelper();
722 class ProgramThreadCountContextHelper {
725 DLLLOCAL ~ProgramThreadCountContextHelper();
726 static ThreadLocalProgramData* getContextFrame(
int& frame,
ExceptionSink* xsink);
727 DLLLOCAL
bool isFirstThreadLocalProgramData(
const ThreadLocalProgramData* tlpd)
const;
731 ThreadLocalProgramData* old_tlpd =
nullptr;
732 ProgramThreadCountContextHelper* old_ctx =
nullptr;
734 int save_frameCount = 0;
735 int old_frameCount = 0;
736 bool restore =
false;
737 bool init_tlpd =
false;
740 class ProgramRuntimeParseContextHelper {
747 DLLLOCAL ~ProgramRuntimeParseContextHelper();
751 class ProgramRuntimeParseCommitContextHelper {
754 ThreadLocalProgramData* old_tlpd;
759 DLLLOCAL ~ProgramRuntimeParseCommitContextHelper();
762 class ProgramRuntimeParseAccessHelper {
765 DLLLOCAL ~ProgramRuntimeParseAccessHelper();
772 class RuntimeReferenceHelperBase {
774 DLLLOCAL RuntimeReferenceHelperBase(
const lvalue_ref& r,
ExceptionSink* n_xsink)
775 : ref(&r), pch(n_xsink, r.pgm, true), osh(r.self, r.cls) {
778 if (thread_ref_set(&r)) {
780 n_xsink->
raiseException(
"CIRCULAR-REFERENCE-ERROR",
"a circular lvalue reference was detected");
785 DLLLOCAL ~RuntimeReferenceHelperBase() {
787 thread_ref_remove(ref);
790 DLLLOCAL
operator bool()
const {
795 const lvalue_ref* ref;
796 ProgramThreadCountContextHelper pch;
797 ObjectSubstitutionHelper osh;
801 class RuntimeReferenceHelper :
public RuntimeReferenceHelperBase {
804 : RuntimeReferenceHelperBase(*lvalue_ref::get(&r), n_xsink) {
807 DLLLOCAL RuntimeReferenceHelper(
const lvalue_ref& r,
ExceptionSink* n_xsink) : RuntimeReferenceHelperBase(r, n_xsink) {
811 class ArgvContextHelper {
815 DLLLOCAL ~ArgvContextHelper();
822 class SingleArgvContextHelper {
827 DLLLOCAL ~SingleArgvContextHelper();
834 class ImplicitElementHelper {
836 DLLLOCAL ImplicitElementHelper(
int n_element) : element(save_implicit_element(n_element)) {
838 DLLLOCAL ~ImplicitElementHelper() {
839 save_implicit_element(element);
846 class CodeContextHelper :
public CodeContextHelperBase {
849 const qore_class_private* cls =
nullptr,
bool ref_obj =
true) :
850 CodeContextHelperBase(c, obj, cls, xs, ref_obj) {
854 DLLLOCAL
void init_qore_threads();
856 DLLLOCAL
void delete_qore_threads();
861 #if defined(HAVE_PTHREAD_GET_STACKSIZE_NP) || (defined(QORE_HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE))
862 #define QORE_HAVE_GET_STACK_SIZE
865 #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)
866 #if defined(HAVE_PTHREAD_GET_NAME_NP) || defined(HAVE_PTHREAD_GETNAME_NP)
867 #define QORE_HAVE_THREAD_NAME
871 class QorePThreadAttr {
876 DLLLOCAL QorePThreadAttr() {
877 pthread_attr_init(&attr);
878 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
881 DLLLOCAL ~QorePThreadAttr() {
883 pthread_attr_destroy(&attr);
887 #ifdef HAVE_PTHREAD_ATTR_GETSTACK
888 DLLLOCAL
void getstack(
void*& ptr,
size_t& ssize) {
889 pthread_attr_getstack(&attr, &ptr, &ssize);
893 DLLLOCAL
size_t getstacksize()
const {
895 pthread_attr_getstacksize(&attr, &ssize);
899 DLLLOCAL
int setstacksize(
size_t ssize) {
900 return pthread_attr_setstacksize(&attr, ssize);
903 DLLLOCAL pthread_attr_t* get_ptr() {
907 #ifdef QORE_HAVE_GET_STACK_SIZE
908 DLLLOCAL
static size_t getCurrentThreadStackSize() {
909 #ifdef HAVE_PTHREAD_GET_STACKSIZE_NP
910 return pthread_get_stacksize_np(pthread_self());
913 if (pthread_getattr_np(pthread_self(), &attr)) {
916 ON_BLOCK_EXIT(pthread_attr_destroy, &attr);
918 if (pthread_attr_getstacksize(&attr, &size)) {
927 DLLLOCAL
extern QorePThreadAttr ta_default;
929 #ifdef QORE_MANAGE_STACK
933 class ParseCodeInfoHelper {
935 const char* parse_code;
936 const QoreTypeInfo* returnTypeInfo;
939 DLLLOCAL ParseCodeInfoHelper(
const char* n_parse_code,
const QoreTypeInfo* n_returnTypeInfo) {
940 parseSetCodeInfo(n_parse_code, n_returnTypeInfo, parse_code, returnTypeInfo);
943 DLLLOCAL ~ParseCodeInfoHelper() {
944 parseRestoreCodeInfo(parse_code, returnTypeInfo);
948 class NamespaceParseContextHelper {
954 DLLLOCAL NamespaceParseContextHelper(qore_ns_private* n_ns) {
955 thread_set_ns(n_ns, ns);
956 restore = (ns != n_ns);
959 DLLLOCAL ~NamespaceParseContextHelper() {
966 class OptionalNamespaceParseContextHelper {
972 DLLLOCAL OptionalNamespaceParseContextHelper(qore_ns_private* n_ns) {
974 thread_set_ns(n_ns, ns);
975 restore = (ns != n_ns);
981 DLLLOCAL ~OptionalNamespaceParseContextHelper() {
988 class QoreParseClassHelper {
990 const qore_class_private* cls;
995 DLLLOCAL QoreParseClassHelper(
QoreClass* new_cls, qore_ns_private* new_ns =
nullptr);
997 DLLLOCAL ~QoreParseClassHelper();
1005 typedef std::set<QoreProgram*> pgm_set_t;
1013 DLLLOCAL
void ref() {
1017 DLLLOCAL ~ThreadProgramData() {
1018 assert(pgm_set.empty());
1022 DLLLOCAL ThreadProgramData(ThreadData* n_td) : td(n_td) {
1026 DLLLOCAL
bool saveProgram(
bool runtime,
ExceptionSink* xsink);
1029 DLLLOCAL
void deref() {
1033 DLLLOCAL
int gettid();
1036 class ThreadFrameBoundaryHelper {
1038 DLLLOCAL ThreadFrameBoundaryHelper(
bool doit) : doit(doit) {
1041 thread_push_frame_boundary();
1045 DLLLOCAL ~ThreadFrameBoundaryHelper() {
1048 thread_pop_frame_boundary();
1056 DLLLOCAL
extern pthread_mutexattr_t ma_recursive;
1057 DLLLOCAL
extern QoreRWLock lck_debug_program;
1059 #ifdef QORE_HAVE_THREAD_NAME
1060 DLLLOCAL
void q_set_thread_name(
const char* name);
1061 DLLLOCAL
void q_get_thread_name(
QoreString& str);
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:48
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:249
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
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:60
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:127
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:409
virtual DLLLOCAL const AbstractStatement * getStatement() const =0
returns the statement for the call for internal Qore code
virtual DLLLOCAL QoreProgram * getProgram() const =0
returns the QoreProgram container
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:90
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values