release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since 892e897 was
ee183be,
checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago
|
Break perlwrap.pm into multiple files.
Break perlwrap.pm out into .pm files in perl/lib. With this commit, we
keep perlwrap.pm around and still load it as before. The next commit
will delete perlwrap.pm and start loading perl files directly from
disk at runtime.
|
-
Property mode set to
100644
|
File size:
705 bytes
|
Rev | Line | |
---|
[ee183be] | 1 | use strict; |
---|
| 2 | use warnings; |
---|
| 3 | |
---|
| 4 | package BarnOwl::Timer; |
---|
| 5 | |
---|
| 6 | sub new { |
---|
| 7 | my $class = shift; |
---|
| 8 | my $args = shift; |
---|
| 9 | |
---|
| 10 | my $cb = $args->{cb}; |
---|
| 11 | die("Invalid callback pased to BarnOwl::Timer\n") unless ref($cb) eq 'CODE'; |
---|
| 12 | |
---|
| 13 | my $self = {cb => $cb}; |
---|
| 14 | |
---|
| 15 | bless($self, $class); |
---|
| 16 | |
---|
| 17 | $self->{timer} = BarnOwl::Internal::add_timer($args->{after} || 0, |
---|
| 18 | $args->{interval} || 0, |
---|
| 19 | $self); |
---|
| 20 | return $self; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | sub do_callback { |
---|
| 24 | my $self = shift; |
---|
| 25 | $self->{cb}->($self); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | sub DESTROY { |
---|
| 29 | my $self = shift; |
---|
| 30 | if(defined($self->{timer})) { |
---|
| 31 | BarnOwl::Internal::remove_timer($self->{timer}); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.