1pod::Prima::Timer(3) User Contributed Perl Documentation pod::Prima::Timer(3)
2
3
4
6 Prima::Timer - programmable periodical events
7
9 my $timer = Prima::Timer-> create(
10 timeout => 1000, # milliseconds
11 onTick => sub {
12 print "tick!\n";
13 },
14 );
15
16 $timer-> start;
17
19 Prima::Timer arranges periodical notifications to be delivered in
20 certain time intervals. The notifications are triggered by the system,
21 and are seen as "Tick" events. There can be many active Timer objects
22 at one time, spawning events simultaneously.
23
25 Prima::Timer is a descendant of Prima::Component. Objects of
26 Prima::Timer class are created in standard fashion:
27
28 my $t = Prima::Timer-> create(
29 timeout => 1000,
30 onTick => sub { print "tick\n"; },
31 );
32 $t-> start;
33
34 If no `owner` is given, $::application is assumed.
35
36 Timer objects are created in inactive state; no events are spawned. To
37 start spawning events, <start()> method must be explicitly called. Time
38 interval value is assigned using the <::timeout> property in
39 milliseconds.
40
41 When the system generates timer event, no callback is called
42 immediately, - an event is pushed into stack instead, to be delivered
43 during next event loop. Therefore, timeout value is not held
44 accurately, and events may take longer time to pass. More accurate
45 timing scheme, as well as timing with precision less than a
46 millisecond, is not supported by the toolkit.
47
49 Properties
50 timeout MILLISECONDS
51 Manages time interval between "Tick" events. In set-mode call, if
52 the timer is in active state ( see "get_active()", the new timeout
53 value is applied immediately.
54
55 Methods
56 get_active
57 Returns a boolean flag, whether object is in active state or not.
58 In the active state "Tick" events are spawned after "::timeout"
59 time intervals.
60
61 get_handle
62 Returns a system-dependent handle of object
63
64 start
65 Sets object in active state. If succeed, or if the object is
66 already in active state, returns 1. If the system was unable to
67 create a system timer instance, 0 is returned.
68
69 stop
70 Sets object in inactive state.
71
72 toggle
73 Toggles the timer state
74
75 Events
76 Tick
77 A system generated event, spawned every "::timeout" milliseconds if
78 object is in active state.
79
81 Dmitry Karasik, <dmitry@karasik.eu.org>.
82
84 Prima, Prima::Object
85
86
87
88perl v5.30.0 2019-08-21 pod::Prima::Timer(3)