|
Qore Programming Language
0.8.3
|
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */ 00002 /* 00003 qore_thread.h 00004 00005 POSIX thread library for Qore 00006 00007 Qore Programming Language 00008 00009 Copyright 2003 - 2011 David Nichols 00010 00011 This library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Lesser General Public 00013 License as published by the Free Software Foundation; either 00014 version 2.1 of the License, or (at your option) any later version. 00015 00016 This library is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public 00022 License along with this library; if not, write to the Free Software 00023 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 */ 00025 00026 #ifndef _QORE_QORE_THREAD_H 00027 #define _QORE_QORE_THREAD_H 00028 00033 #include <stdio.h> 00034 #include <pthread.h> 00035 00036 class QoreProgram; 00037 class AbstractQoreZoneInfo; 00038 class ThreadCleanupNode; 00039 class AbstractThreadResource; 00040 00042 typedef void (*qtdest_t)(void *); 00043 00045 typedef void (*qtrdest_t)(void *, ExceptionSink *); 00046 00048 DLLEXPORT bool is_valid_qore_thread(); 00049 00051 DLLEXPORT int gettid(); 00052 00054 DLLEXPORT QoreProgram *getProgram(); 00055 00057 DLLEXPORT const AbstractQoreZoneInfo *currentTZ(); 00058 00060 00062 DLLEXPORT void set_thread_resource(AbstractThreadResource *atr); 00063 00065 00068 DLLEXPORT int remove_thread_resource(AbstractThreadResource *atr); 00069 00071 00077 DLLEXPORT void set_thread_resource_id(q_trid_t trid, AbstractThreadResource *atr); 00078 00080 00085 DLLEXPORT int remove_thread_resource_id(q_trid_t trid); 00086 00088 00091 DLLEXPORT bool check_thread_resource_id(q_trid_t trid); 00092 00094 DLLEXPORT q_trid_t qore_get_trid(); 00095 00097 00104 class ThreadCleanupList { 00105 private: 00106 static ThreadCleanupNode *head; 00107 00108 public: 00109 DLLLOCAL ThreadCleanupList(); 00110 DLLLOCAL ~ThreadCleanupList(); 00111 DLLLOCAL void exec(); 00112 00114 00117 DLLEXPORT void push(qtdest_t func, void *arg); 00118 00120 00122 DLLEXPORT void pop(bool exec = true); 00123 }; 00124 00126 DLLEXPORT extern ThreadCleanupList tclist; 00127 00128 #endif // ifndef _QORE_THREAD_H