thread.h

来源:互联网 发布:windows安装snmp 编辑:程序博客网 时间:2024/06/05 08:33
00001 /*00002  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics00003  *               http://gearbox.sf.net/00004  * Copyright (c) 2004-2010 Alex Brooks, Alexei Makarenko, Tobias Kaupp00005  *00006  * This distribution is licensed to you under the terms described in00007  * the LICENSE file included in this distribution.00008  *00009  */00010 00011 #ifndef GBXICEUTILACFR_THREAD_H00012 #define GBXICEUTILACFR_THREAD_H00013 00014 #include <IceUtil/Thread.h>00015 #include <gbxutilacfr/stoppable.h>00016 // this is not needed for implementation of this class.00017 // it's included for convenience of users of Thread class.00018 #include <gbxsickacfr/gbxiceutilacfr/threadutils.h>00019 00020 namespace gbxiceutilacfr {00021 00072 class Thread : public IceUtil::Thread, public gbxutilacfr::Stoppable00073 {00074 public:00075 00076     Thread();00077 00080     void stop();00081 00082     // from gbxutilacfr::Stoppable00084     virtual bool isStopping();00085 00087     bool isStarted();00088 00092     bool isActive() { return !isStopping(); };00093 00094 protected:00095 00100     void waitForStop();00101 00102 private:00103     bool isStopping_;00104 };00106 typedef IceUtil::Handle<gbxiceutilacfr::Thread> ThreadPtr;00107 00110 void stop( gbxiceutilacfr::Thread* thread );00111 00114 void stopAndJoin( gbxiceutilacfr::Thread* thread );00115 00118 inline void stop( const gbxiceutilacfr::ThreadPtr& thread )00119 { stop(thread.get()); }00120 00123 inline void stopAndJoin( const gbxiceutilacfr::ThreadPtr& thread )00124 { stopAndJoin(thread.get()); }00125 00126 } // end namespace00127 00128 #endif