Switch to unified view

a b/src/index/rclmon.h
1
#ifndef _RCLMON_H_INCLUDED_
2
#define _RCLMON_H_INCLUDED_
3
/* @(#$Id: rclmon.h,v 1.1 2006-10-16 15:33:08 dockes Exp $  (C) 2006 J.F.Dockes */
4
/**
5
 * Definitions for the real-time monitoring recoll. 
6
 * We're interested in file modifications, deletions and renaming.
7
 * We use two threads, one to receive events from the source, the
8
 * other to perform adequate processing.
9
 *
10
 * The two threads communicate through an event buffer which is
11
 * actually a hash map indexed by file path for easy coalescing of
12
 * multiple events to the same file.
13
 */
14
15
#include <string>
16
#include <map>
17
18
#include "rclconfig.h"
19
20
#ifndef NO_NAMESPACES
21
using std::string;
22
using std::multimap;
23
#endif
24
25
class RclMonEvent {
26
 public: 
27
    enum EvType {RCLEVT_NONE, RCLEVT_MODIFY, RCLEVT_DELETE, RCLEVT_RENAME};
28
    string m_path;
29
    string m_opath;
30
    EvType m_etyp;
31
    RclMonEvent() : m_etyp(RCLEVT_NONE) {}
32
};
33
34
class RclEQData;
35
36
class RclMonEventQueue {
37
 public:
38
    RclMonEventQueue();
39
    ~RclMonEventQueue();
40
    /** Unlock queue and wait until there are new events. 
41
     *  Returns with the queue locked */
42
    bool wait();
43
    /** Unlock queue */
44
    bool unlock();
45
    /** Lock queue. */
46
    bool lock();
47
    /** Lock queue and add event. */
48
    bool pushEvent(const RclMonEvent &ev);
49
    void setTerminate(); /* To all threads: end processing */
50
    bool ok();
51
    bool empty();
52
    RclMonEvent pop();
53
54
    // Convenience function for initially communicating config to mon thr
55
    void setConfig(RclConfig *conf);
56
    RclConfig *getConfig();
57
58
 private:
59
    RclEQData *m_data;
60
};
61
62
extern RclMonEventQueue rclEQ;
63
extern bool startMonitor(RclConfig *conf, bool nofork);
64
65
#endif /* _RCLMON_H_INCLUDED_ */