00001
00002
00003
00004
00005 #ifndef __WVBATCHSIGNAL_H
00006 #define __WVBATCHSIGNAL_H
00007
00008 #include <uniconf.h>
00009 #include <wvistreamlist.h>
00010 #include <wvtr1.h>
00011
00012
00013 class WvInvertedStream: public WvStream
00014 {
00015 public:
00016 WvInvertedStream(char *_id):
00017 WvStream()
00018 {
00019 WvIStreamList::globallist.append(this, false, _id);
00020 }
00021 ~WvInvertedStream()
00022 {
00023 WvIStreamList::globallist.unlink(this);
00024 }
00025 };
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class WvBellPull
00042 {
00043 public:
00044 WvBellPull(WvCallback<> _cb):
00045 cb(_cb),
00046 bellpull(new WvInvertedStream("bellpull"))
00047 {
00048 bellpull->setcallback(
00049 WvStreamCallback(this, &WvBellPull::bellpull_cb), NULL);
00050 }
00051
00052 WvBellPull(const WvBellPull& _other):
00053 cb(_other.cb),
00054 bellpull(_other.bellpull)
00055 {
00056 bellpull->addRef();
00057 }
00058
00059 ~WvBellPull()
00060 {
00061 bellpull->release();
00062 }
00063 void delay(time_t msec_timeout)
00064 {
00065 bellpull->alarm(msec_timeout);
00066 }
00067 void cancel()
00068 {
00069 bellpull->alarm(-1);
00070 }
00071 void operator()()
00072 {
00073 bellpull->alarm(0);
00074 }
00075 void operator()(IWvStream&)
00076 {
00077 bellpull->alarm(0);
00078 }
00079 void operator()(WvStream&, void*)
00080 {
00081 bellpull->alarm(0);
00082 }
00083 void operator()(const UniConf &, const UniConfKey &)
00084 {
00085 bellpull->alarm(0);
00086 }
00087
00088 private:
00089 WvCallback<> cb;
00090 WvInvertedStream *bellpull;
00091
00092 void bellpull_cb(WvStream&, void*)
00093 {
00094 cb();
00095 }
00096 };
00097
00098 #endif