Fawkes API
Fawkes Development Version
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
29
/** @class FamThread <utils/system/fam_thread.h>
30
* FileAlterationMonitor thread wrapper.
31
* This thread wraps a FileAlterationMonitor and runs it continuously possibly
32
* causing FAM events in this thread context. This thread is useful if you have
33
* no good place to call FileAlterationMonitor::process_events() in your
34
* part.
35
* @author Tim Niemueller
36
*/
37
38
/** Constructor.
39
* @param fam optional RefPtr to FileAlterationMonitor. If none is given
40
* one is instantiated by the FamThread instance.
41
*/
42
FamThread::FamThread
(RefPtr<FileAlterationMonitor> fam)
43
: Thread(
"FileAlterationMonitorThread"
, Thread::OPMODE_CONTINUOUS)
44
{
45
fam_ = fam;
46
if
(!fam_) {
47
fam_ = RefPtr<FileAlterationMonitor>(
new
FileAlterationMonitor());
48
}
49
}
50
51
/** Get FileAlterationMonitor.
52
* @return shared pointer to FileAlterationMonitor instance.
53
*/
54
RefPtr<FileAlterationMonitor>
55
FamThread::get_fam
()
56
{
57
return
fam_;
58
}
59
60
void
61
FamThread::loop
()
62
{
63
fam_->process_events(-1);
64
usleep(0);
65
}
66
67
}
// end of namespace fawkes
fawkes::FamThread::loop
virtual void loop()
Code to execute in the thread.
Definition:
fam_thread.cpp:67
fawkes
fawkes::FamThread::get_fam
RefPtr< FileAlterationMonitor > get_fam()
Get FileAlterationMonitor.
Definition:
fam_thread.cpp:61
fawkes::FamThread::FamThread
FamThread(RefPtr< FileAlterationMonitor > fam=RefPtr< FileAlterationMonitor >())
Constructor.
Definition:
fam_thread.cpp:48
src
libs
utils
system
fam_thread.cpp
Generated by
1.8.17