# thread.h

Go to the documentation of this file.

    00001 /* $Id: thread.h 17776 2009-10-15 17:41:06Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef THREAD_H
    00013 #define THREAD_H
    00014
    00015 typedef void (*OTTDThreadFunc)(void *);
    00016
    00017 class OTTDThreadExitSignal { };
    00018
    00022 class ThreadObject {
    00023 public:
    00027   virtual ~ThreadObject() {};
    00028
    00032   virtual bool Exit() = 0;
    00033
    00037   virtual void Join() = 0;
    00038
    00047   static bool New(OTTDThreadFunc proc, void *param, ThreadObject **thread = NULL);
    00048 };
    00049
    00053 class ThreadMutex {
    00054 public:
    00055   static ThreadMutex *New();
    00056
    00060   virtual ~ThreadMutex() {};
    00061
    00065   virtual void BeginCritical() = 0;
    00066
    00070   virtual void EndCritical() = 0;
    00071
    00078   virtual void WaitForSignal() = 0;
    00079
    00083   virtual void SendSignal() = 0;
    00084 };
    00085
    00086 #endif /* THREAD_H */