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 int gettid(); 00043 00045 DLLEXPORT class QoreProgram *getProgram(); 00046 00048 00050 DLLEXPORT void set_thread_resource(class AbstractThreadResource *atr); 00051 00053 00056 DLLEXPORT int remove_thread_resource(class AbstractThreadResource *atr); 00057 00059 00066 class ThreadCleanupList { 00067 private: 00068 static class ThreadCleanupNode *head; 00069 00070 public: 00071 DLLLOCAL ThreadCleanupList(); 00072 DLLLOCAL ~ThreadCleanupList(); 00073 DLLLOCAL void exec(); 00074 00076 00079 DLLEXPORT void push(qtdest_t func, void *arg); 00080 00082 00084 DLLEXPORT void pop(bool exec = true); 00085 }; 00086 00088 DLLEXPORT extern ThreadCleanupList tclist; 00089 00090 #endif // ifndef _QORE_THREAD_H