diff options
| author | cvs2svn <admin@example.com> | 2008-02-28 06:10:55 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2008-02-28 06:10:55 +0000 |
| commit | f676de20d91ba1cc58b8eaaf2f6b931851c2063a (patch) | |
| tree | 69a3aa7a4da079ef4de5aa12ab0563d2945f2a23 /tools/future.h | |
| parent | 4e3b041c65f36dd8729ca2b5fe224461a2166f6d (diff) | |
| download | xineliboutput-f676de20d91ba1cc58b8eaaf2f6b931851c2063a.tar.gz xineliboutput-f676de20d91ba1cc58b8eaaf2f6b931851c2063a.tar.bz2 | |
This commit was manufactured by cvs2svn to create branch 'unlabeled-1.3.2'.
Diffstat (limited to 'tools/future.h')
| -rw-r--r-- | tools/future.h | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/tools/future.h b/tools/future.h deleted file mode 100644 index bdd0498c..00000000 --- a/tools/future.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * future.h: A variable that gets its value in future. - * Used to convert asynchronous IPCs to synchronous. - * - * See the main source file 'xineliboutput.c' for copyright information and - * how to reach the author. - * - * $Id: future.h,v 1.2 2006-08-19 23:44:07 phintuka Exp $ - * - */ - -#ifndef __FUTURE_H -#define __FUTURE_H - -#include <vdr/thread.h> - -template <class T> -class cFuture { - - private: - cMutex mutex; - cCondVar cond; - bool m_Ready; - T m_Value; - - public: - - cFuture() - { - m_Ready = false; - } - - void Reset(void) - { - cMutexLock l(&mutex); - m_Ready = false; - } - - // - // Producer interface - // - - void Set(T& Value) - { - cMutexLock l(&mutex); - m_Value = Value; - m_Ready = true; - cond.Broadcast(); - } - - // - // Consumer interface - // - - bool Wait(int Timeout = -1) - { - cMutexLock l(&mutex); - - if(Timeout==0 || m_Ready) - return m_Ready; - - if(Timeout >= 0) - return cond.TimedWait(mutex, Timeout) && m_Ready; - - while(!m_Ready) - cond.Wait(mutex); - - return m_Ready; - } - - bool IsReady(void) - { - cMutexLock l(&mutex); - return m_Ready; - } - - T Value(void) - { - cMutexLock l(&mutex); - while(!m_Ready) - cond.Wait(mutex); - return m_Value; - } -}; - - -#endif // __FUTURE_H |
