]> git.ipfire.org Git - people/stevee/guardian.git/commitdiff
Use TimeHires core module for main loop interupting.
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 24 Nov 2015 12:20:41 +0000 (13:20 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Tue, 24 Nov 2015 12:20:41 +0000 (13:20 +0100)
Using the TimeHires module and interupting the main loop for
10 miliseconds will reduce the cpu load of guardian to almost
zero instead of burning it.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
guardian

index 2ec8ac4b4cf59cd7399b4767d5a2e9183dc1cb23..af5caebf152c89b473a0b42fc476fc53b951a63e 100644 (file)
--- a/guardian
+++ b/guardian
@@ -25,6 +25,7 @@ use threads::shared;
 use Getopt::Long;
 use Thread::Queue;
 use Linux::Inotify2;
+use Time::HiRes qw[ time sleep ];
 
 require Guardian::Config;
 require Guardian::Parser;
@@ -90,9 +91,8 @@ while(1) {
                $queue->dequeue();
        }
 
-       # XXX
-       # Temporary workaround to reduce the load of the main process.
-       sleep(1);
+       # Sleep 10ms to reduce the load of the main process.
+       sleep(0.01);
 }
 
 #