00001 #ifndef SAFE_CALLBACK_CLASS 00002 #define SAFE_CALLBACK_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : safe_callback * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 2001-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include <basis/astring.h> 00019 #include <basis/mutex.h> 00020 #include <basis/contracts.h> 00021 00022 namespace processes { 00023 00024 // forward. 00025 class callback_data_block; 00026 class global_live_objects; 00027 00029 00067 class safe_callback 00068 { 00069 public: 00070 safe_callback(); 00072 00073 void end_availability(); 00075 00079 virtual ~safe_callback(); 00081 00085 DEFINE_CLASS_NAME("safe_callback"); 00086 00087 bool decoupled() const { return _decoupled; } 00089 00094 bool invoke_callback(callback_data_block &new_data); 00096 00113 protected: 00114 virtual void real_callback(callback_data_block &new_data) = 0; 00116 00119 private: 00120 bool _decoupled; 00121 basis::mutex *_callback_lock; 00122 void begin_availability(); 00124 00126 public: 00127 global_live_objects &_invocables(); 00129 00131 }; 00132 00134 00136 00141 class callback_data_block 00142 { 00143 public: 00144 virtual ~callback_data_block(); 00145 }; 00146 00148 00149 } //namespace. 00150 00151 #endif 00152
1.6.3