]> source.dussan.org Git - tigervnc.git/commitdiff
Improved the interface of the PollingScheduler class, added some
authorConstantin Kaplinsky <const@tightvnc.com>
Thu, 16 Feb 2006 16:44:50 +0000 (16:44 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Thu, 16 Feb 2006 16:44:50 +0000 (16:44 +0000)
documentation in comments.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@494 3789f03b-4d11-0410-bbf8-ca57d06f2519

x0vncserver/PollingScheduler.cxx
x0vncserver/PollingScheduler.h
x0vncserver/x0vncserver.cxx

index 2d28491669da54d708f2088c9c8cb74f439a0210..ee315967e352dd5327dbc981bc298f525c2ddd0c 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 //
-// PollingScheduler.cxx
+// PollingScheduler class implementation.
 //
 
 #include <x0vncserver/PollingScheduler.h>
@@ -58,3 +58,7 @@ int PollingScheduler::millisRemaining() const
   return (m_interval - elapsed);
 }
 
+bool PollingScheduler::goodTimeToPoll() const
+{
+  return (millisRemaining() == 0);
+}
index 777a66503243b9e404bcbc4898f254cb8bfbbccf..ba7b27dd27426e2ef536a54d8e88fc1699ffb57a 100644 (file)
  */
 
 //
-// PollingScheduler.h
+// PollingScheduler class. It is used for deciding when to start new
+// polling pass, and how much time it is ok to wait before starting. 
+// PollingScheduler is provided a desired polling interval and watches
+// for actual intervals between past polling cycles.
 //
 
 #ifndef __POLLINGSCHEDULER_H__
@@ -43,6 +46,9 @@ public:
   // This function estimates time remaining before new polling pass.
   int millisRemaining() const;
 
+  // This function tells if it's ok to start polling pass right now.
+  bool goodTimeToPoll() const;
+
 protected:
 
   bool initialState;
index 27c130a42f3f5b331d6094e05e896d5a76b1f8f3..d179d943e326de4cc23b0c8a07b3da10d7b26aa3 100644 (file)
@@ -485,7 +485,7 @@ int main(int argc, char** argv)
 
       server.checkTimeouts();
 
-      if (sched.millisRemaining() <= 0) {
+      if (sched.goodTimeToPoll()) {
         adjustPollingCycle(&dynPollingCycle, &cpumon);
         sched.setInterval(dynPollingCycle);
         sched.newPass();