00001 00002 /*************************************************************************** 00003 * blocked_timing.h - Blocked timing aspect for Fawkes 00004 * 00005 * Created: Thu Jan 11 16:52:28 2007 00006 * Copyright 2006-2007 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <aspect/blocked_timing.h> 00025 #include <core/threading/thread.h> 00026 00027 namespace fawkes { 00028 00029 /** @class BlockedTimingAspect <aspect/blocked_timing.h> 00030 * Thread aspect to use blocked timing 00031 * The Fawkes main application provides basic means to synchronize all 00032 * running thread with respect to several given hooks (see WakeupHook). 00033 * Threads of a woken up at a particular point in time. The hooks basically 00034 * correspond to an extended sense - plan - act kind of loop. 00035 * Your thread must run in Thread::OPMODE_WAITFORWAKEUP mode, otherwise it 00036 * is not started. This is a requirement for having the BlockedTimingAspect. 00037 * 00038 * @see Thread::OpMode 00039 * @ingroup Aspects 00040 * @author Tim Niemueller 00041 * 00042 */ 00043 00044 // Side note: Overriding Thread::run() can make our requirement useless, but 00045 // we believe in the best of the coder: laziness 00046 00047 /** Constructor. 00048 * This special constructor is needed to define the wakeup point. 00049 * @param wakeup_hook hook when this thread should be woken up 00050 */ 00051 BlockedTimingAspect::BlockedTimingAspect(WakeupHook wakeup_hook) 00052 { 00053 this->wakeup_hook = wakeup_hook; 00054 } 00055 00056 00057 /** Virtual empty destructor. */ 00058 BlockedTimingAspect::~BlockedTimingAspect() 00059 { 00060 } 00061 00062 00063 /** Get the wakeup hook. 00064 * The wakeup hook defines when this thread should be woken up. This heavily 00065 * depends on the used main thread. 00066 * @return wakeup hook 00067 */ 00068 BlockedTimingAspect::WakeupHook 00069 BlockedTimingAspect::blockedTimingAspectHook() const 00070 { 00071 return wakeup_hook; 00072 } 00073 00074 } // end namespace fawkes