Annotation of fam/fam/Activity.c++, Revision 1.1.1.1
1.1 trev 1: // Copyright (C) 1999 Silicon Graphics, Inc. All Rights Reserved.
2: //
3: // This program is free software; you can redistribute it and/or modify it
4: // under the terms of version 2 of the GNU General Public License as
5: // published by the Free Software Foundation.
6: //
7: // This program is distributed in the hope that it would be useful, but
8: // WITHOUT ANY WARRANTY; without even the implied warranty of
9: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, any
10: // license provided herein, whether implied or otherwise, is limited to
11: // this program in accordance with the express provisions of the GNU
12: // General Public License. Patent licenses, if any, provided herein do not
13: // apply to combinations of this program with other product or programs, or
14: // any other product whatsoever. This program is distributed without any
15: // warranty that the program is delivered free of the rightful claim of any
16: // third person by way of infringement or the like. See the GNU General
17: // Public License for more details.
18: //
19: // You should have received a copy of the GNU General Public License along
20: // with this program; if not, write the Free Software Foundation, Inc., 59
21: // Temple Place - Suite 330, Boston MA 02111-1307, USA.
22:
23: #include "Activity.h"
24:
25: #include <unistd.h>
26:
27: #include "Log.h"
28: #include "Scheduler.h"
29:
30: unsigned Activity::idle_time = default_timeout;
31: unsigned Activity::count;
32:
33: Activity::Activity()
34: {
35: if ((count++ == 0) && (idle_time > 0))
36: Scheduler::remove_onetime_task(task, NULL);
37: }
38:
39: Activity::Activity(const Activity&)
40: {
41: Activity();
42: }
43:
44: Activity::~Activity()
45: {
46: if ((--count == 0) && (idle_time > 0))
47: { timeval t;
48: (void) gettimeofday(&t, NULL);
49: t.tv_sec += idle_time;
50: Scheduler::install_onetime_task(t, task, NULL);
51: }
52: }
53:
54: void
55: Activity::task(void *)
56: {
57: Log::debug("exiting after %d second%s of inactivity",
58: idle_time, idle_time == 1 ? "" : "s");
59: Scheduler::exit();
60: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>