00001 /* 00002 qore_thread.h 00003 00004 POSIX thread library for Qore 00005 00006 Qore Programming Language 00007 00008 Copyright 2003 - 2009 David Nichols 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00023 */ 00024 00025 #ifndef _QORE_QORE_THREAD_H 00026 #define _QORE_QORE_THREAD_H 00027 00032 #include <stdio.h> 00033 #include <pthread.h> 00034 00036 typedef void (*qtdest_t)(void *); 00037 00039 typedef void (*qtrdest_t)(void *, class ExceptionSink *); 00040 00042 DLLEXPORT bool is_valid_qore_thread(); 00043 00045 DLLEXPORT int gettid(); 00046 00048 DLLEXPORT class QoreProgram *getProgram(); 00049 00051 00053 DLLEXPORT void set_thread_resource(class AbstractThreadResource *atr); 00054 00056 00059 DLLEXPORT int remove_thread_resource(class AbstractThreadResource *atr); 00060 00062 00069 class ThreadCleanupList { 00070 private: 00071 static class ThreadCleanupNode *head; 00072 00073 public: 00074 DLLLOCAL ThreadCleanupList(); 00075 DLLLOCAL ~ThreadCleanupList(); 00076 DLLLOCAL void exec(); 00077 00079 00082 DLLEXPORT void push(qtdest_t func, void *arg); 00083 00085 00087 DLLEXPORT void pop(bool exec = true); 00088 }; 00089 00091 DLLEXPORT extern ThreadCleanupList tclist; 00092 00093 #endif // ifndef _QORE_THREAD_H