wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / unislowgen.h
blob5b739443f1ab3c08a15ecc89a69c5438c579cf8a
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002 Net Integration Technologies, Inc.
4 *
5 * A UniConfGen that makes everything slow.
6 */
7 #ifndef __UNISLOWGEN_H
8 #define __UNISLOWGEN_H
10 #include "unifiltergen.h"
12 /**
13 * A UniConfGen that counts all "potentially synchronous" (ie. slow)
14 * operations, so you'll know for sure if you're calling UniConf synchronous
15 * operations when you shouldn't be. Hint: wrapping this one in a
16 * UniCacheGen is supposed to cut slow operations to a bare minimum, so a
17 * good test is to try a moniker like this:
19 * cache:slow:tcp:localhost
21 * ...and see if everything still works but there are no slow operations.
23 * (A previous version of this used to actually make things slow by doing
24 * a deliberate sleep() on synchronous operations, but that wasn't really
25 * needed. Now it just logs them instead.)
27 class UniSlowGen : public UniFilterGen
29 public:
30 UniSlowGen(IUniConfGen *inner);
31 virtual ~UniSlowGen();
33 virtual void commit();
34 virtual bool refresh();
35 virtual void flush_buffers() { }
36 virtual WvString get(const UniConfKey &key);
37 virtual bool exists(const UniConfKey &key);
38 virtual bool haschildren(const UniConfKey &key);
39 virtual Iter *iterator(const UniConfKey &key);
40 virtual Iter *recursiveiterator(const UniConfKey &key);
42 int how_slow() const
43 { return slowcount; }
45 void reset_slow()
46 { slowcount = 0; }
48 private:
49 int slowcount;
51 void be_slow(WvStringParm what);
52 void be_slow(WVSTRING_FORMAT_DECL)
53 { be_slow(WvString(WVSTRING_FORMAT_CALL)); }
56 #endif //__UNISLOWGEN_H