From: Stefan Schantl Date: Tue, 24 Nov 2015 12:20:41 +0000 (+0100) Subject: Use TimeHires core module for main loop interupting. X-Git-Tag: 2.0~73 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=01147a7edbba0b8705ac5b2873ca127bff30da15 Use TimeHires core module for main loop interupting. 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 --- diff --git a/guardian b/guardian index 2ec8ac4..af5caeb 100644 --- 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); } #