Annotation of fam/fam/Pollster.h, Revision 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: #ifndef Pollster_included
! 24: #define Pollster_included
! 25:
! 26: #include <sys/time.h>
! 27: #include <stdlib.h>
! 28:
! 29: #include "Boolean.h"
! 30: #include "Set.h"
! 31:
! 32: class Interest;
! 33: class ServerHost;
! 34:
! 35: // The Pollster remembers what needs to be polled, and wakes up every
! 36: // few seconds to poll it. The Pollster polls Interests and Hosts.
! 37: // Each Host, if it can't connect to remote fam, polls its own Interests.
! 38: //
! 39: // The Pollster's polling interval can be set or interrogated.
! 40: // Also, remote polling can be enabled or disabled using enable()
! 41: // or disable() (corresponds to "fam -l").
! 42: //
! 43: // When there's nothing to poll, the Pollster turns itself off, so
! 44: // fam can sleep for a long time.
! 45: //
! 46: // Pollster is not instantiated; instead, a bunch of static methods
! 47: // implement its interface.
! 48:
! 49: class Pollster {
! 50:
! 51: public:
! 52:
! 53: static void watch(Interest *);
! 54: static void forget(Interest *);
! 55:
! 56: static void watch(ServerHost *);
! 57: static void forget(ServerHost *);
! 58:
! 59: static void interval(unsigned secs) { pintvl.tv_sec = (long)secs; }
! 60: static unsigned interval() { return pintvl.tv_sec; }
! 61: static void enable() { remote_polling_enabled = true; }
! 62: static void disable() { remote_polling_enabled = false; }
! 63:
! 64: private:
! 65:
! 66: // Class Variables
! 67:
! 68: static bool remote_polling_enabled;
! 69: static timeval pintvl; // polling interval
! 70: static Set<Interest *> polled_interests;
! 71: static Set<ServerHost *> polled_hosts;
! 72: static bool polling;
! 73:
! 74: // Private Class Methods
! 75:
! 76: static void polling_task(void *closure);
! 77: static void start_polling();
! 78: static void stop_polling();
! 79:
! 80: Pollster(); // Do not instantiate.
! 81:
! 82: };
! 83:
! 84: #endif /* !Pollster_included */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>