wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / wvbellpull.h
blob496ce331927d70426e96f98dc3bfd66a9f8e6d02
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 */
5 #ifndef __WVBATCHSIGNAL_H
6 #define __WVBATCHSIGNAL_H
8 #include <uniconf.h>
9 #include <wvistreamlist.h>
10 #include <wvtr1.h>
13 class WvInvertedStream: public WvStream
15 public:
16 WvInvertedStream(char *_id):
17 WvStream()
19 WvIStreamList::globallist.append(this, false, _id);
21 ~WvInvertedStream()
23 WvIStreamList::globallist.unlink(this);
29 * This class is a functor compatible with UniConfCallback,
30 * IWvStreamCallback and WvStreamCallback, as well as supporting being
31 * called with no parameters.
33 * It will turn any number of calls to any of these callbacks into a
34 * single call to the callback you give to it, which will be sent on
35 * the next run through the main loop.
37 * Think of it as an elevator button: pressing it a bunch of times has
38 * no more effect than pressing it once, and while it doesn't do what
39 * you tell it right away, it will do it soon enough.
41 class WvBellPull
43 public:
44 WvBellPull(WvCallback<> _cb):
45 cb(_cb),
46 bellpull(new WvInvertedStream("bellpull"))
48 bellpull->setcallback(
49 WvStreamCallback(this, &WvBellPull::bellpull_cb), NULL);
52 WvBellPull(const WvBellPull& _other):
53 cb(_other.cb),
54 bellpull(_other.bellpull)
56 bellpull->addRef();
59 ~WvBellPull()
61 bellpull->release();
63 void delay(time_t msec_timeout)
65 bellpull->alarm(msec_timeout);
67 void cancel()
69 bellpull->alarm(-1);
71 void operator()()
73 bellpull->alarm(0);
75 void operator()(IWvStream&)
77 bellpull->alarm(0);
79 void operator()(WvStream&, void*)
81 bellpull->alarm(0);
83 void operator()(const UniConf &, const UniConfKey &)
85 bellpull->alarm(0);
88 private:
89 WvCallback<> cb;
90 WvInvertedStream *bellpull;
92 void bellpull_cb(WvStream&, void*)
94 cb();
98 #endif /* __WVBATCHSIGNAL_H */