From 01147a7edbba0b8705ac5b2873ca127bff30da15 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Tue, 24 Nov 2015 13:20:41 +0100 Subject: [PATCH] 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 --- guardian | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); } # -- 2.39.2