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 49 #define QORE_STACK_GUARD (1024 * 32) 54 #define QORE_STACK_GUARD (1024 * 22) 57 #if defined(HPUX) && !defined(__ia64) && !defined(__LP64__) 59 #define QORE_STACK_GUARD (1024 * 10) 63 #define QORE_STACK_GUARD (1024 * 8) 68 #endif // QORE_STACK_GUARD 77 class ClosureParseEnvironment;
78 class QoreClosureBase;
79 hashdecl ClosureVarValue;
82 class qore_ns_private;
83 class qore_root_ns_private;
84 class qore_class_private;
85 class AbstractQoreFunctionVariant;
86 class AbstractQoreZoneInfo;
87 class ThreadProgramData;
88 hashdecl ThreadLocalProgramData;
89 class QoreAbstractModule;
92 DLLLOCAL
extern Operator* OP_BACKGROUND;
95 class AbstractQoreZoneInfo;
98 hashdecl ModuleContextNamespaceCommit {
99 qore_ns_private* parent;
100 qore_ns_private* nns;
102 DLLLOCAL ModuleContextNamespaceCommit(qore_ns_private* n_parent, qore_ns_private* n_nns) : parent(n_parent), nns(n_nns) {
106 typedef std::vector<ModuleContextNamespaceCommit> mcnl_t;
108 class ModuleContextNamespaceList :
public mcnl_t {
111 DLLLOCAL ModuleContextNamespaceList(
const ModuleContextNamespaceList&);
114 DLLLOCAL ModuleContextNamespaceList() {
117 DLLLOCAL ~ModuleContextNamespaceList() {
121 DLLLOCAL
void clear();
124 hashdecl ModuleContextFunctionCommit {
125 qore_ns_private* parent;
127 AbstractQoreFunctionVariant* v;
129 DLLLOCAL ModuleContextFunctionCommit(qore_ns_private* n_parent,
const char* n_name, AbstractQoreFunctionVariant* n_v) : parent(n_parent), name(n_name), v(n_v) {
133 typedef std::vector<ModuleContextFunctionCommit> mcfl_t;
135 class ModuleContextFunctionList :
public mcfl_t {
138 DLLLOCAL ModuleContextFunctionList(
const ModuleContextFunctionList&);
141 DLLLOCAL ModuleContextFunctionList() {
144 DLLLOCAL ~ModuleContextFunctionList() {
148 DLLLOCAL
void clear();
151 class QoreModuleContext {
153 ModuleContextNamespaceList mcnl;
154 ModuleContextFunctionList mcfl;
156 DLLLOCAL QoreModuleContext(
const char* n, qore_root_ns_private* n_rns,
ExceptionSink& xs) : name(n), rns(n_rns), xsink(xs) {
159 DLLLOCAL ~QoreModuleContext() {
163 DLLLOCAL
void error(
const char* fmt, ...);
165 DLLLOCAL
bool hasError()
const {
169 DLLLOCAL
void commit();
171 DLLLOCAL
void rollback() {
176 DLLLOCAL qore_root_ns_private* getRootNS()
const {
180 DLLLOCAL
const char* getName()
const {
186 qore_root_ns_private* rns;
191 class QoreModuleDefContext {
193 typedef std::set<std::string> strset_t;
194 typedef std::map<std::string, std::string> strmap_t;
199 const QoreProgramLocation* init_loc,
202 DLLLOCAL QoreModuleDefContext() {
205 DLLLOCAL ~QoreModuleDefContext() {
211 static strset_t vset;
216 DLLLOCAL
void set(
const QoreProgramLocation* loc,
const char* key,
QoreValue val);
218 DLLLOCAL
const char*
get(
const char* str)
const {
219 strmap_t::const_iterator i = vmap.find(str);
220 return i == vmap.end() || i->second.empty() ? nullptr : i->second.c_str();
223 DLLLOCAL
void parseInit();
230 DLLLOCAL
void initClosure(
const QoreProgramLocation* loc,
QoreValue& c,
const char* n);
236 DLLLOCAL
int purge_thread_resources_to_mark(
ExceptionSink* xsink);
239 DLLLOCAL
void mark_thread_resources();
240 DLLLOCAL
void beginParsing(
const char* file,
void* ps = NULL,
const char* src =
nullptr,
int offset = 0);
241 DLLLOCAL
void* endParsing();
242 DLLLOCAL Context* get_context_stack();
243 DLLLOCAL
void update_context_stack(Context* cstack);
247 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm);
249 const AbstractStatement*& current_stmt,
QoreProgram*& current_pgm,
const QoreProgramLocation*& old_runtime_loc);
251 DLLLOCAL
void update_runtime_stack_location(
const QoreStackLocation* stack_loc,
const QoreProgramLocation* runtime_loc);
253 DLLLOCAL
const QoreProgramLocation* get_runtime_location();
254 DLLLOCAL
void update_get_runtime_statement_location(
const AbstractStatement* stmt,
255 const QoreProgramLocation* loc,
const AbstractStatement*& old_stmt,
const QoreProgramLocation*& old_loc);
256 DLLLOCAL
void update_runtime_statement_location(
const AbstractStatement* stmt,
const QoreProgramLocation* loc);
258 DLLLOCAL
void set_parse_file_info(QoreProgramLocation& loc);
259 DLLLOCAL
const char* get_parse_code();
261 DLLLOCAL
const AbstractStatement* get_runtime_statement();
263 DLLLOCAL
const QoreTypeInfo* parse_set_implicit_arg_type_info(
const QoreTypeInfo* ti);
264 DLLLOCAL
const QoreTypeInfo* parse_get_implicit_arg_type_info();
266 DLLLOCAL
int64 parse_get_parse_options();
267 DLLLOCAL
int64 runtime_get_parse_options();
269 DLLLOCAL
bool parse_check_parse_option(
int64 o);
270 DLLLOCAL
bool runtime_check_parse_option(
int64 o);
273 DLLLOCAL
void updateCVarStack(CVNode* ncvs);
274 DLLLOCAL CVNode* getCVarStack();
275 DLLLOCAL
void updateVStack(VNode* nvs);
276 DLLLOCAL VNode* getVStack();
280 DLLLOCAL qore_class_private* parse_get_class_priv();
281 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);
282 DLLLOCAL
void thread_set_class_and_ns(
const qore_class_private* new_cls, qore_ns_private* new_ns);
283 DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns, qore_ns_private*& old_ns);
284 DLLLOCAL
void thread_set_ns(qore_ns_private* new_ns);
285 DLLLOCAL qore_ns_private* parse_get_ns();
287 DLLLOCAL
void substituteObjectIfEqual(
QoreObject* o);
289 DLLLOCAL QoreException* catchSwapException(QoreException* e);
290 DLLLOCAL QoreException* catchGetException();
291 DLLLOCAL VLock* getVLock();
293 DLLLOCAL
void delete_thread_local_data();
294 DLLLOCAL
void parse_cond_push(
bool mark =
false);
295 DLLLOCAL
bool parse_cond_else();
296 DLLLOCAL
bool parse_cond_pop(
const QoreProgramLocation* loc);
297 DLLLOCAL
bool parse_cond_test(
const QoreProgramLocation* loc);
298 DLLLOCAL
void push_parse_options();
299 DLLLOCAL
void parse_try_module_inc();
300 DLLLOCAL
bool parse_try_module_dec(
const QoreProgramLocation* loc);
301 DLLLOCAL
unsigned parse_try_module_get();
302 DLLLOCAL
void parse_try_module_set(
unsigned c);
304 DLLLOCAL
void parse_push_name(
const char* name);
305 DLLLOCAL std::string parse_pop_name();
307 DLLLOCAL
void set_module_context(QoreModuleContext* qmc);
308 DLLLOCAL QoreModuleContext* get_module_context();
309 DLLLOCAL QoreModuleDefContext* set_module_def_context(QoreModuleDefContext* qmd);
310 DLLLOCAL QoreModuleDefContext* get_module_def_context();
311 DLLLOCAL
void parse_set_module_def_context_name(
const char* name);
312 DLLLOCAL
const char* set_user_module_context_name(
const char* n);
313 DLLLOCAL
const char* get_user_module_context_name();
314 DLLLOCAL
const char* get_module_context_name();
316 DLLLOCAL
void parse_set_try_reexport(
bool tr);
317 DLLLOCAL
bool parse_get_try_reexport();
319 DLLLOCAL
void set_thread_tz(
const AbstractQoreZoneInfo* tz);
320 DLLLOCAL
const AbstractQoreZoneInfo* get_thread_tz(
bool&
set);
321 DLLLOCAL
void clear_thread_tz();
323 DLLLOCAL ThreadProgramData* get_thread_program_data();
324 DLLLOCAL ThreadLocalProgramData* get_thread_local_program_data();
326 DLLLOCAL
int thread_ref_set(
const lvalue_ref* r);
327 DLLLOCAL
void thread_ref_remove(
const lvalue_ref* r);
330 DLLLOCAL
void new_argv_ref();
333 DLLLOCAL
void inc_argv_ref();
336 DLLLOCAL
void push_ignore_numeric_argv_ref();
339 DLLLOCAL
void pop_ignore_numeric_argv_ref();
342 DLLLOCAL
void inc_numeric_argv_ref();
345 DLLLOCAL
int get_pop_argv_ref();
348 DLLLOCAL
void clear_argv_ref();
350 DLLLOCAL
int set_constant(ConstantEntry* ce);
351 DLLLOCAL
void remove_constant(ConstantEntry* ce);
353 DLLLOCAL QoreAbstractModule* set_reexport(QoreAbstractModule* m,
bool current_reexport,
bool& old_reexport);
354 DLLLOCAL
void set_reexport(QoreAbstractModule* m,
bool reexport);
356 DLLLOCAL
void parseSetCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo,
const char*& old_code,
const QoreTypeInfo*& old_returnTypeInfo);
357 DLLLOCAL
void parseRestoreCodeInfo(
const char* parse_code,
const QoreTypeInfo* returnTypeInfo);
359 DLLLOCAL
const QoreTypeInfo* saveReturnTypeInfo(
const QoreTypeInfo* returnTypeInfo);
360 DLLLOCAL
const QoreTypeInfo* getReturnTypeInfo();
362 DLLLOCAL
const QoreTypeInfo* parse_get_return_type_info();
365 DLLLOCAL
void set_program_call_context(
QoreProgram* new_pgm);
368 class LVarStackBreakHelper {
370 DLLLOCAL LVarStackBreakHelper();
371 DLLLOCAL ~LVarStackBreakHelper();
377 class ProgramCallContextHelper {
379 DLLLOCAL ProgramCallContextHelper(
QoreProgram* new_pgm)
380 : pgm(new_pgm ? get_set_program_call_context(new_pgm) : reinterpret_cast<
QoreProgram*>(-1)) {
383 DLLLOCAL ~ProgramCallContextHelper() {
384 if (pgm != reinterpret_cast<QoreProgram*>(-1)) {
385 set_program_call_context(pgm);
393 class ModuleReExportHelper {
395 QoreAbstractModule* m;
399 DLLLOCAL ModuleReExportHelper(QoreAbstractModule* mi,
bool reexp);
400 DLLLOCAL ~ModuleReExportHelper();
403 class QoreParseCountContextHelper {
408 DLLLOCAL QoreParseCountContextHelper() : count(parse_try_module_get()) {
409 parse_try_module_set(0);
412 DLLLOCAL ~QoreParseCountContextHelper() {
413 parse_try_module_set(count);
417 class QoreProgramStackLocationHelper {
419 DLLLOCAL QoreProgramStackLocationHelper(
QoreStackLocation* stack_loc,
const AbstractStatement*& current_stmt,
421 stack_loc(update_get_runtime_stack_location(stack_loc, current_stmt, current_pgm)) {
424 DLLLOCAL ~QoreProgramStackLocationHelper() {
425 update_runtime_stack_location(stack_loc);
432 class QoreInternalCallStackLocationHelperBase :
public QoreStackLocation,
public QoreProgramStackLocationHelper {
434 DLLLOCAL QoreInternalCallStackLocationHelperBase() : QoreProgramStackLocationHelper(this, stmt, pgm) {
441 DLLLOCAL
virtual const AbstractStatement* getStatement()
const {
446 const AbstractStatement* stmt;
450 class QoreInternalCallStackLocationHelper :
public QoreInternalCallStackLocationHelperBase {
452 DLLLOCAL QoreInternalCallStackLocationHelper(
const QoreProgramLocation& loc,
const std::string& call,
453 qore_call_t call_type) : loc(loc), call(call), call_type(call_type) {
457 DLLLOCAL
virtual const QoreProgramLocation& getLocation()
const {
462 DLLLOCAL
virtual const std::string& getCallName()
const {
466 DLLLOCAL
virtual qore_call_t getCallType()
const {
471 const QoreProgramLocation& loc;
472 const std::string call;
473 qore_call_t call_type;
476 class QoreProgramLocationHelper {
478 DLLLOCAL QoreProgramLocationHelper(
const QoreProgramLocation* n_loc,
const AbstractStatement* n_stat =
nullptr) {
479 update_get_runtime_statement_location(n_stat, n_loc, statement, loc);
482 DLLLOCAL ~QoreProgramLocationHelper() {
483 update_runtime_statement_location(statement, loc);
487 const QoreProgramLocation* loc;
488 const AbstractStatement* statement;
491 class QoreProgramOptionalLocationHelper {
493 DLLLOCAL QoreProgramOptionalLocationHelper(
const QoreProgramLocation* n_loc,
const AbstractStatement* n_stat =
nullptr) : restore((bool)n_loc) {
495 update_get_runtime_statement_location(n_stat, n_loc, statement, loc);
499 DLLLOCAL ~QoreProgramOptionalLocationHelper() {
501 update_runtime_statement_location(statement, loc);
506 const QoreProgramLocation* loc;
507 const AbstractStatement* statement;
512 class CurrentProgramRuntimeParseContextHelper {
515 DLLEXPORT CurrentProgramRuntimeParseContextHelper();
517 DLLEXPORT ~CurrentProgramRuntimeParseContextHelper();
521 CurrentProgramRuntimeParseContextHelper(
const CurrentProgramRuntimeParseContextHelper&) =
delete;
522 void*
operator new(size_t) =
delete;
526 class ParseImplicitArgTypeHelper {
528 DLLLOCAL ParseImplicitArgTypeHelper(
const QoreTypeInfo* ti) : ati(parse_set_implicit_arg_type_info(ti)) {
531 DLLLOCAL ~ParseImplicitArgTypeHelper() {
532 parse_set_implicit_arg_type_info(ati);
536 const QoreTypeInfo* ati;
540 DLLLOCAL
int get_thread_entry();
542 DLLLOCAL
int get_signal_thread_entry();
543 DLLLOCAL
void deregister_signal_thread();
544 DLLLOCAL
void register_thread(
int tid, pthread_t ptid,
QoreProgram* pgm,
bool foreign =
false);
545 DLLLOCAL
void deregister_thread(
int tid);
546 DLLLOCAL
void delete_signal_thread();
553 DLLLOCAL
void pushBlock(block_list_t::iterator i);
555 DLLLOCAL block_list_t::iterator popBlock();
557 DLLLOCAL
void advanceOnBlockExit();
559 DLLLOCAL LocalVarValue* thread_instantiate_lvar();
560 DLLLOCAL
void thread_uninstantiate_lvar(
ExceptionSink* xsink);
561 DLLLOCAL
void thread_uninstantiate_self();
563 DLLLOCAL
void thread_set_closure_parse_env(ClosureParseEnvironment* cenv);
564 DLLLOCAL ClosureParseEnvironment* thread_get_closure_parse_env();
566 DLLLOCAL ClosureVarValue* thread_instantiate_closure_var(
const char*
id,
const QoreTypeInfo* typeInfo,
QoreValue& nval,
bool assign);
567 DLLLOCAL
void thread_instantiate_closure_var(ClosureVarValue* cvar);
568 DLLLOCAL
void thread_uninstantiate_closure_var(
ExceptionSink* xsink);
569 DLLLOCAL ClosureVarValue* thread_find_closure_var(
const char*
id);
571 DLLLOCAL ClosureVarValue* thread_get_runtime_closure_var(
const LocalVar*
id);
572 DLLLOCAL
const QoreClosureBase* thread_set_runtime_closure_env(
const QoreClosureBase* current);
574 typedef std::vector<ClosureVarValue*> cvv_vec_t;
575 DLLLOCAL cvv_vec_t* thread_get_all_closure_vars();
577 DLLLOCAL
void thread_push_frame_boundary();
578 DLLLOCAL
void thread_pop_frame_boundary();
582 DLLLOCAL
int thread_set_local_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
584 DLLLOCAL
int thread_set_closure_var_value(
int frame,
const char* name,
const QoreValue& val,
ExceptionSink* xsink);
586 DLLLOCAL
int get_implicit_element();
587 DLLLOCAL
int save_implicit_element(
int n_element);
589 DLLLOCAL VNode* update_get_vstack(VNode* vn);
590 DLLLOCAL
void save_global_vnode(VNode* vn);
591 DLLLOCAL VNode* get_global_vnode();
593 class QoreContainerHelper {
602 if (!thread_push_container(n_n)) {
616 DLLLOCAL ~QoreContainerHelper() {
618 thread_pop_container(n);
620 DLLLOCAL
operator bool ()
const {
625 DLLLOCAL
const QoreListNode* thread_get_implicit_args();
627 DLLLOCAL LocalVarValue* thread_find_lvar(
const char*
id);
630 DLLLOCAL
QoreObject* runtime_get_stack_object();
632 DLLLOCAL
const qore_class_private* runtime_get_class();
633 DLLLOCAL
void runtime_get_object_and_class(
QoreObject*& obj,
const qore_class_private*& qc);
635 DLLLOCAL
bool runtime_in_object_method(
const char* name,
const QoreObject* o);
637 class CodeContextHelperBase {
639 const char* old_code;
641 const qore_class_private* old_class;
649 DLLLOCAL CodeContextHelperBase(
const char* code,
QoreObject* obj,
const qore_class_private* c,
ExceptionSink* xsink,
bool ref_obj =
true);
650 DLLLOCAL ~CodeContextHelperBase();
653 class ObjectSubstitutionHelper {
656 const qore_class_private* old_class;
659 DLLLOCAL ObjectSubstitutionHelper(
QoreObject* obj,
const qore_class_private* c);
660 DLLLOCAL ~ObjectSubstitutionHelper();
663 class OptionalClassObjSubstitutionHelper {
665 DLLLOCAL OptionalClassObjSubstitutionHelper(
const qore_class_private* qc);
666 DLLLOCAL ~OptionalClassObjSubstitutionHelper();
670 const qore_class_private* old_class;
674 class OptionalClassOnlySubstitutionHelper {
676 DLLLOCAL OptionalClassOnlySubstitutionHelper(
const qore_class_private* qc);
677 DLLLOCAL ~OptionalClassOnlySubstitutionHelper();
680 const qore_class_private* old_class;
684 class OptionalObjectOnlySubstitutionHelper {
686 DLLLOCAL OptionalObjectOnlySubstitutionHelper(
QoreObject* obj);
687 DLLLOCAL ~OptionalObjectOnlySubstitutionHelper();
694 class ThreadSafeLocalVarRuntimeEnvironmentHelper {
696 const QoreClosureBase* prev;
699 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironmentHelper(
const QoreClosureBase* current);
700 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironmentHelper();
703 typedef std::map<const LocalVar*, ClosureVarValue*> cvar_map_t;
704 typedef std::set<ClosureVarValue*> cvv_set_t;
706 class ThreadSafeLocalVarRuntimeEnvironment {
712 DLLLOCAL ThreadSafeLocalVarRuntimeEnvironment(
const lvar_set_t* vlist);
713 DLLLOCAL ~ThreadSafeLocalVarRuntimeEnvironment();
714 DLLLOCAL ClosureVarValue* find(
const LocalVar*
id)
const;
715 DLLLOCAL
bool hasVar(ClosureVarValue* cvv)
const;
718 DLLLOCAL
bool empty() {
722 DLLLOCAL
const cvar_map_t& getMap()
const {
727 hashdecl ThreadLocalProgramData;
729 class QoreProgramBlockParseOptionHelper {
731 DLLLOCAL QoreProgramBlockParseOptionHelper(
int64 n_po);
732 DLLLOCAL ~QoreProgramBlockParseOptionHelper();
738 class ProgramThreadCountContextHelper {
741 DLLLOCAL ~ProgramThreadCountContextHelper();
742 static ThreadLocalProgramData* getContextFrame(
int& frame,
ExceptionSink* xsink);
743 bool isFirstThreadLocalProgramData(
const ThreadLocalProgramData* tlpd)
const;
747 ThreadLocalProgramData* old_tlpd =
nullptr;
748 ProgramThreadCountContextHelper* old_ctx =
nullptr;
750 int save_frameCount = 0;
752 bool restore =
false;
753 bool init_tlpd =
false;
756 class ProgramRuntimeParseContextHelper {
763 DLLLOCAL ~ProgramRuntimeParseContextHelper();
767 class ProgramRuntimeParseCommitContextHelper {
770 ThreadLocalProgramData* old_tlpd;
775 DLLLOCAL ~ProgramRuntimeParseCommitContextHelper();
778 class ProgramRuntimeParseAccessHelper {
785 DLLLOCAL ~ProgramRuntimeParseAccessHelper();
788 class RuntimeReferenceHelperBase {
790 const lvalue_ref* ref;
791 ProgramThreadCountContextHelper pch;
792 ObjectSubstitutionHelper osh;
796 DLLLOCAL RuntimeReferenceHelperBase(
const lvalue_ref& r,
ExceptionSink* n_xsink)
797 : ref(&r), pch(n_xsink, r.pgm, true), osh(r.self, r.cls) {
799 if (thread_ref_set(&r)) {
801 n_xsink->
raiseException(
"CIRCULAR-REFERENCE-ERROR",
"a circular lvalue reference was detected");
806 DLLLOCAL ~RuntimeReferenceHelperBase() {
808 thread_ref_remove(ref);
811 DLLLOCAL
operator bool()
const {
816 class RuntimeReferenceHelper :
public RuntimeReferenceHelperBase {
818 DLLLOCAL RuntimeReferenceHelper(
const ReferenceNode& r,
ExceptionSink* n_xsink) : RuntimeReferenceHelperBase(*lvalue_ref::get(&r), n_xsink) {
821 DLLLOCAL RuntimeReferenceHelper(
const lvalue_ref& r,
ExceptionSink* n_xsink) : RuntimeReferenceHelperBase(r, n_xsink) {
825 class ArgvContextHelper {
833 DLLLOCAL ~ArgvContextHelper();
836 class SingleArgvContextHelper {
845 DLLLOCAL ~SingleArgvContextHelper();
848 class ImplicitElementHelper {
853 DLLLOCAL ImplicitElementHelper(
int n_element) : element(save_implicit_element(n_element)) {
855 DLLLOCAL ~ImplicitElementHelper() {
856 save_implicit_element(element);
860 class CodeContextHelper :
public CodeContextHelperBase {
862 DLLLOCAL CodeContextHelper(
ExceptionSink* xs,
int t,
const char* c,
QoreObject* obj =
nullptr,
const qore_class_private* cls =
nullptr,
bool ref_obj =
true) :
863 CodeContextHelperBase(c, obj, cls, xs, ref_obj) {
867 DLLLOCAL
void init_qore_threads();
869 DLLLOCAL
void delete_qore_threads();
874 #if defined(QORE_HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE) 875 #define QORE_HAVE_GET_STACK_SIZE 878 #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) 879 #define QORE_HAVE_THREAD_NAME 882 class QorePThreadAttr {
887 DLLLOCAL QorePThreadAttr() {
888 pthread_attr_init(&attr);
889 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
892 DLLLOCAL ~QorePThreadAttr() {
894 pthread_attr_destroy(&attr);
898 #ifdef HAVE_PTHREAD_ATTR_GETSTACK 899 DLLLOCAL
void getstack(
void*& ptr,
size_t& ssize) {
900 pthread_attr_getstack(&attr, &ptr, &ssize);
904 DLLLOCAL
size_t getstacksize()
const {
906 pthread_attr_getstacksize(&attr, &ssize);
910 DLLLOCAL
int setstacksize(
size_t ssize) {
911 return pthread_attr_setstacksize(&attr, ssize);
914 DLLLOCAL pthread_attr_t* get_ptr() {
918 #ifdef QORE_HAVE_GET_STACK_SIZE 919 DLLLOCAL
static size_t getCurrentThreadStackSize() {
921 if (pthread_getattr_np(pthread_self(), &attr)) {
924 ON_BLOCK_EXIT(pthread_attr_destroy, &attr);
926 if (pthread_attr_getstacksize(&attr, &size)) {
934 DLLLOCAL
extern QorePThreadAttr ta_default;
936 #ifdef QORE_MANAGE_STACK 940 class ParseCodeInfoHelper {
942 const char* parse_code;
943 const QoreTypeInfo* returnTypeInfo;
946 DLLLOCAL ParseCodeInfoHelper(
const char* n_parse_code,
const QoreTypeInfo* n_returnTypeInfo) {
947 parseSetCodeInfo(n_parse_code, n_returnTypeInfo, parse_code, returnTypeInfo);
950 DLLLOCAL ~ParseCodeInfoHelper() {
951 parseRestoreCodeInfo(parse_code, returnTypeInfo);
955 class NamespaceParseContextHelper {
961 DLLLOCAL NamespaceParseContextHelper(qore_ns_private* n_ns) {
962 thread_set_ns(n_ns, ns);
963 restore = (ns != n_ns);
966 DLLLOCAL ~NamespaceParseContextHelper() {
973 class OptionalNamespaceParseContextHelper {
979 DLLLOCAL OptionalNamespaceParseContextHelper(qore_ns_private* n_ns) {
981 thread_set_ns(n_ns, ns);
982 restore = (ns != n_ns);
988 DLLLOCAL ~OptionalNamespaceParseContextHelper() {
995 class QoreParseClassHelper {
997 const qore_class_private* cls;
1002 DLLLOCAL QoreParseClassHelper(
QoreClass* new_cls, qore_ns_private* new_ns =
nullptr);
1004 DLLLOCAL ~QoreParseClassHelper();
1012 typedef std::set<QoreProgram*> pgm_set_t;
1020 DLLLOCAL
void ref() {
1024 DLLLOCAL ~ThreadProgramData() {
1025 assert(pgm_set.empty());
1029 DLLLOCAL ThreadProgramData(ThreadData* n_td) : td(n_td) {
1033 DLLLOCAL
bool saveProgram(
bool runtime,
ExceptionSink* xsink);
1036 DLLLOCAL
void deref() {
1037 if (ROdereference())
1043 class ThreadFrameBoundaryHelper {
1045 DLLLOCAL ThreadFrameBoundaryHelper(
bool doit) : doit(doit) {
1048 thread_push_frame_boundary();
1052 DLLLOCAL ~ThreadFrameBoundaryHelper() {
1055 thread_pop_frame_boundary();
1063 DLLLOCAL
extern pthread_mutexattr_t ma_recursive;
1064 DLLLOCAL
extern QoreRWLock lck_debug_program;
1066 #ifdef QORE_HAVE_THREAD_NAME 1067 DLLLOCAL
void q_set_thread_name(
const char* name);
1068 DLLLOCAL
void q_get_thread_name(
QoreString& str);
DLLLOCAL qore_type_t getType() const
returns the data type
Definition: AbstractQoreNode.h:172
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
Stack location element abstract class.
Definition: ExceptionSink.h:396
DLLEXPORT int gettid() noexcept
returns the current TID number
const qore_type_t NT_LIST
type value for QoreListNode
Definition: node_types.h:50
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
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
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:64
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:81
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram
the root namespace of a QoreProgram object
Definition: QoreNamespace.h:286
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
provides atomic reference counting to Qore objects
Definition: QoreReferenceCounter.h:44
defines a Qore-language class
Definition: QoreClass.h:239
parse type: reference to a lvalue expression
Definition: ReferenceNode.h:45
const qore_type_t NT_HASH
type value for QoreHashNode
Definition: node_types.h:51
#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:262
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:126
the implementation of Qore's object data type, reference counted, dynamically-allocated only ...
Definition: QoreObject.h:61
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
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
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:70
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:47
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:47
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values ...