Switch to using alarm instead of delay to stop skewing.
[picture-display.git] / lib / Display / Plugin.pm
index 0405ca411f9cc63de2f9ae80d3cfb7b08a74e82a..bd31c06225f0aa9409d457a0bda469c0ccb45f64 100644 (file)
@@ -19,4 +19,20 @@ sub new {
   return $self;
 }
 
+sub init_delay {
+  my ($self, $delay, $event) = @_;
+
+  $self->{'_next_check'} = time();
+  $self->{'_next_delay'} = $delay;
+  $self->{'_next_event'} = $event;
+}
+
+sub delay {
+  my $self = shift;
+
+  $self->{'_next_check'} += $self->{'_next_delay'};
+
+  $self->{'kernel'}->alarm( $self->{'_next_event'} => $self->{'_next_check'} );
+}
+
 1;