00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef LIBMUTH_SUSPENDER_DECLS_H
00020 #define LIBMUTH_SUSPENDER_DECLS_H
00021
00022 #include "refcounter_decls.h"
00023 #include "lock.h"
00024 #include "microthread.h"
00025
00032 template<class T> class Suspender : public RefCounter {
00033 private:
00034 mutable Lock lock;
00035 Microthread *microthread;
00036 bool wakened;
00037 T retval;
00041 Suspender() : microthread(NULL), wakened(false) {}
00042 public:
00047 inline static Suspender &create() { return *new Suspender(); }
00053 T suspend();
00062 bool wakeup(const T &rv);
00071 bool cooperativewakeup(const T &rv);
00078 inline bool issuspended() const;
00083 inline bool iswakened() const;
00089 inline bool iscompleted() const;
00090
00091 };
00092
00093 #endif