![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Waitable object base type * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 *********************************************************************************/ 00022 #ifndef FXWAITABLE_H 00023 #define FXWAITABLE_H 00024 00025 #ifndef FXTHREADEDOBJECT_H 00026 #include "FXThreadedObject.h" 00027 #endif 00028 namespace FXEX { 00029 00030 /** 00031 * A base class for controlling sequenced / waitable events. 00032 * 00033 * On activate()/activateALL() the main thread is sent a FOX event. This helps to 00034 * reduce the complexity of synchronisation programming required by the application 00035 * programmer. 00036 */ 00037 class FXAPI FXWaitable : public FXThreadedObject { 00038 FXDECLARE_ABSTRACT(FXWaitable) 00039 00040 public: 00041 enum { 00042 ID_ACTIVATE=FXThreadedObject::ID_LAST, 00043 ID_ACTIVATE_ALL, 00044 ID_LAST 00045 }; 00046 00047 public: 00048 long onActivate(FXObject*,FXSelector,void*); 00049 long onActivateAll(FXObject*,FXSelector,void*); 00050 00051 protected: 00052 // ctor for child classes to inherit from 00053 FXWaitable(FXObject *tgt=NULL,FXSelector=0); 00054 00055 public: 00056 /// Wait indefinately for some condition 00057 virtual void wait(); 00058 00059 /// Wait for some condition, or time out 00060 virtual FXbool trywait(FXuint ms); 00061 00062 /** 00063 * Activate object to stop waiting 00064 * Note: other threading toolkits somtimes call this signal(), 00065 * but we have another use for that name 00066 */ 00067 virtual void activate(); 00068 00069 /// signal all objects to stop waiting 00070 virtual void activateAll(); 00071 00072 /// dtor 00073 virtual ~FXWaitable(); 00074 }; 00075 00076 } // namespace FXEX 00077 #endif // FXWAITABLE_H