Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

WaitSet.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * ウェイトセットヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef WAIT_SET_H_
00026 #define WAIT_SET_H_
00027 
00028 #include <Core/Thread/LockObject.h>
00029 #include <Core/Container/Deque.h>
00030 
00031 namespace Lamp{
00032 
00033 class Thread;
00034 
00035 //------------------------------------------------------------------------------
00036 /**
00037  * ウェイトセット
00038  */
00039 class WaitSet : public LockObject{
00040 public:
00041     /**
00042      * コンストラクタ
00043      *
00044      * クリティカルセクションによる同期制御を行う
00045      */
00046     WaitSet();
00047 
00048     /**
00049      * コンストラクタ
00050      * @param lockObject ロックオブジェクト
00051      * @param deleteLockObject ロックオブジェクトをWaitSetが削除するならtrue
00052      */
00053     WaitSet(LockObject* lockObject, bool deleteLockObject);
00054 
00055     /**
00056      * デストラクタ
00057      */
00058     virtual ~WaitSet();
00059 
00060     //--------------------------------------------------------------------------
00061     /**
00062      * 待機
00063      * @param thread 待機させるスレッド
00064      *
00065      * 引数のスレッドを待機させます。呼び出すにはWaitSetに対するロックが必要。
00066      * カレントスレッド版より高速に動作します。
00067      */
00068     virtual void wait(const Thread* thread);
00069 
00070     /**
00071      * 待機
00072      * カレントスレッドを待機させます。呼び出すにはWaitSetに対するロックが必要。
00073      */
00074     virtual void wait();
00075 
00076     /**
00077      * 待機解除
00078      *
00079      * 一つのスレッドの待機を解除します。呼び出すにはWaitSetに対するロックが必要。
00080      */
00081     virtual void notify();
00082 
00083     /**
00084      * 待機全解除
00085      *
00086      * 全てのスレッドの待機を解除します。呼び出すにはWaitSetに対するロックが必要。
00087      */
00088     virtual void notifyAll();
00089 
00090     //--------------------------------------------------------------------------
00091     /**
00092      * ロック
00093      */
00094     virtual void lock(){ lockObject_->lock(); }
00095 
00096     /**
00097      * アンロック
00098      */
00099     virtual void unlock(){ lockObject_->unlock(); }
00100 
00101     /**
00102      * カレントスレッドによってロックされているか
00103      * @return カレントスレッドによってロックされていればtrue
00104      */
00105     virtual bool isLockedByCurrentThread() const{
00106         return lockObject_->isLockedByCurrentThread();
00107     }
00108 
00109 private:
00110     // スレッド配列
00111     Deque<HANDLE> waitingThreads_;
00112     // ロックオブジェクト
00113     LockObject* lockObject_;
00114     // ロックオブジェクト削除フラグ
00115     bool deleteLockObject_;
00116 
00117 };
00118 
00119 //------------------------------------------------------------------------------
00120 } // End of namespace Lamp
00121 #endif // End of WAIT_SET_H_
00122 //------------------------------------------------------------------------------
00123 

Generated on Wed Mar 16 10:29:38 2005 for Lamp by doxygen 1.3.2