Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
fam_thread.cpp
1
2
/***************************************************************************
3
* fam_thread.cpp - File Alteration Monitor Thread
4
*
5
* Created: Sat Jan 24 12:30:10 2009
6
* Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include <utils/system/fam_thread.h>
24
25
#include <unistd.h>
26
27
namespace
fawkes {
28
#if 0
/* just to make Emacs auto-indent happy */
29
}
30
#endif
31
32
/** @class FamThread <utils/system/fam_thread.h>
33
* FileAlterationMonitor thread wrapper.
34
* This thread wraps a FileAlterationMonitor and runs it continuously possibly
35
* causing FAM events in this thread context. This thread is useful if you have
36
* no good place to call FileAlterationMonitor::process_events() in your
37
* part.
38
* @author Tim Niemueller
39
*/
40
41
/** Constructor.
42
* @param fam optional RefPtr to FileAlterationMonitor. If none is given
43
* one is instantiated by the FamThread instance.
44
*/
45
FamThread::FamThread(
RefPtr<FileAlterationMonitor>
fam)
46
:
Thread
(
"FileAlterationMonitorThread"
,
Thread
::OPMODE_CONTINUOUS)
47
{
48
__fam = fam;
49
if
(! __fam) {
50
__fam =
RefPtr<FileAlterationMonitor>
(
new
FileAlterationMonitor
());
51
}
52
}
53
54
/** Get FileAlterationMonitor.
55
* @return shared pointer to FileAlterationMonitor instance.
56
*/
57
RefPtr<FileAlterationMonitor>
58
FamThread::get_fam
()
59
{
60
return
__fam;
61
}
62
63
64
void
65
FamThread::loop
()
66
{
67
__fam->
process_events
(-1);
68
usleep(0);
69
}
70
71
}
// end of namespace fawkes
src
libs
utils
system
fam_thread.cpp
Generated by
1.8.1.2