Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * executor.h - Interface to exec BlockedTimingAspect threads 00004 * 00005 * Created: Sat Aug 02 13:03:29 2008 00006 * Copyright 2006-2008 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/executor.h> 00025 00026 namespace fawkes { 00027 00028 /** @class BlockedTimingExecutor <aspect/blocked_timing/executor.h> 00029 * Blocked timing executor. 00030 * This interface defines access to threads with the blocked timing aspect. 00031 * @author Tim Niemueller 00032 * 00033 * @fn void BlockedTimingExecutor::wakeup_and_wait(BlockedTimingAspect::WakeupHook hook, unsigned int timeout_usec) 00034 * Wakeup thread for given hook and wait for completion. 00035 * This will wakeup all threads registered for the given hook. Afterwards 00036 * this method will block until all threads finished their loop. 00037 * @param hook hook for which to wait for 00038 * @param timeout_usec timeout for thread execution in usec. 0 disables the 00039 * timeout and makes this function to wait forever. 00040 * @exception Exception thrown if the timeout was exceeded (at least one of the 00041 * threads for the given hook took longer than the desired time. 00042 * 00043 * @fn void BlockedTimingExecutor::wakeup(BlockedTimingAspect::WakeupHook hook, Barrier *barrier = 0) 00044 * Wakeup thread for given hook. 00045 * This will wakeup all threads registered for the given hook. With the optional 00046 * barrier you can synchronize to the end of the loop execution of the threads 00047 * of the given hook. 00048 * @param hook hook for which to wait for 00049 * @param barrier optional barrier that can be used to synchronize to the 00050 * end of the loop execution of the threads. 00051 * 00052 * @fn void BlockedTimingExecutor::try_recover(std::list<std::string> &recovered_threads) 00053 * Try to recover threads. 00054 * An advanced BlockedTimingExecutor might be able to detect deadlocked threads. 00055 * In this case this function should be called regularly to allow for recovering 00056 * threads that are back to normal operation. 00057 * @param recovered_threads upon return the names of any threads that could be 00058 * recovered from a bad state have been added to the list. 00059 * 00060 * @fn bool BlockedTimingExecutor::timed_threads_exist() 00061 * Check if any timed threads exist. 00062 * @return true if threads exist that need to be woken up for execution, false 00063 * otherwise 00064 * 00065 * @fn void BlockedTimingExecutor::wait_for_timed_threads() 00066 * Wait for timed threads. 00067 * Use this method to wait until a timed that is added to the thread manager. 00068 * Note that an InterruptedException is thrown if interrup_timed_thread_wait() is 00069 * called from another thread. You should catch this exception and stop the loop 00070 * execution. 00071 * @exception InterruptedException thrown if another thread calls 00072 * interrupt_timed_thread_wait() 00073 * 00074 * @fn void BlockedTimingExecutor::interrupt_timed_thread_wait() 00075 * Interrupt any currently running wait_for_timed_threads() and cause it to 00076 * throw an InterruptedException. 00077 * 00078 */ 00079 00080 /** Virtual empty destructor. */ 00081 BlockedTimingExecutor::~BlockedTimingExecutor() 00082 { 00083 } 00084 00085 } // end namespace fawkes