00001 /*00002 * The Software License00003 * =================================================================================00004 * Copyright (c) 2003-.The Terimber Corporation. All rights reserved.00005 * =================================================================================00006 * Redistributions of source code must retain the above copyright notice, 00007 * this list of conditions and the following disclaimer.00008 * Redistributions in binary form must reproduce the above copyright notice, 00009 * this list of conditions and the following disclaimer in the documentation 00010 * and/or other materials provided with the distribution.00011 * The end-user documentation included with the redistribution, if any, 00012 * must include the following acknowledgment:00013 * "This product includes software developed by the Terimber Corporation."00014 * =================================================================================00015 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00017 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE TERIMBER CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR 00019 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00022 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE00024 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.00025 * ================================================================================00026 */00027
00028 #ifndef _terimber_msg_base_h_00029 #define _terimber_msg_base_h_00030
00031 #include "base/primitives.h"00032
00033
00034 BEGIN_TERIMBER_NAMESPACE00035 #pragma pack(4)00036
00037 // forward declaration00038 class msg_communicator;
00039
00041 // class implements the base functionality for thread activity00042class msg_base00043 {
00044 public:
00046 msg_base(msg_communicator* communicator_
00047 );
00049 virtual~msg_base();
00052 void00053 on();
00055 void00056 off();
00058 inline00059 bool00060is_on() const 00061 {
00062 mutex_keeper keeper(_mtx_res);
00063 return_on;
00064 }
00065 protected:
00067 inline00068 void00069set_on(bool on)
00070 {
00071 mutex_keeper keeper(_mtx_res);
00072 _on = on;
00073 }
00074
00076 virtual00077 void00078v_on()
00079 {
00080 set_on(true);
00081 }
00083 virtual00084 void00085v_off()
00086 {
00087 set_on(false);
00088 }
00089 protected:
00090msg_communicator* _communicator;
00091mutex_mtx_res;
00092bool_on;
00093 };
00094
00095 #pragma pack()00096 END_TERIMBER_NAMESPACE00097
00098 #endif // _terimber_msg_base_h_00099