# thread.h

Go to the documentation of this file.

    00001 /* $Id: thread.h 24900 2013-01-08 22:46:42Z planetmaker $ */
    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
    00016 typedef void (*OTTDThreadFunc)(void *);
    00017
    00019 class OTTDThreadExitSignal { };
    00020
    00024 class ThreadObject {
    00025 public:
    00029   virtual ~ThreadObject() {};
    00030
    00034   virtual bool Exit() = 0;
    00035
    00039   virtual void Join() = 0;
    00040
    00049   static bool New(OTTDThreadFunc proc, void *param, ThreadObject **thread = NULL);
    00050 };
    00051
    00055 class ThreadMutex {
    00056 public:
    00060   static ThreadMutex *New();
    00061
    00065   virtual ~ThreadMutex() {};
    00066
    00070   virtual void BeginCritical() = 0;
    00071
    00075   virtual void EndCritical() = 0;
    00076
    00083   virtual void WaitForSignal() = 0;
    00084
    00088   virtual void SendSignal() = 0;
    00089 };
    00090
    00095 uint GetCPUCoreCount();
    00096
    00097 #endif /* THREAD_H */