posixtimer 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/posixtimer.c +18 -14
- data/test/timertests.rb +2 -0
- metadata +3 -3
data/ext/posixtimer.c
CHANGED
@@ -52,20 +52,6 @@ static VALUE timer_alloc(VALUE klass)
|
|
52
52
|
return obj;
|
53
53
|
}
|
54
54
|
|
55
|
-
/* call-seq:
|
56
|
-
* Posix::Timer.new
|
57
|
-
* Posix::Timer.new("ALRM")
|
58
|
-
* Posix::Timer.new("USR1")
|
59
|
-
* Posix::Timer.new { some_block }
|
60
|
-
*
|
61
|
-
* Create a new Posix::Timer object. The argument passed can be any valid
|
62
|
-
* signal type from Signal.list.
|
63
|
-
*
|
64
|
-
* If a block is passed, that block will be executed when the Posix::Timer timeout
|
65
|
-
* has expired. This is done by trapping the signal specified as creation time, so
|
66
|
-
* be careful if you have other uses of that signal in your program.
|
67
|
-
*
|
68
|
-
*/
|
69
55
|
static VALUE timer_initialize(int argc, VALUE *argv, VALUE self)
|
70
56
|
{
|
71
57
|
VALUE sigtype, codeblock;
|
@@ -97,11 +83,26 @@ static VALUE timer_initialize(int argc, VALUE *argv, VALUE self)
|
|
97
83
|
data->sig_event = &data->se;
|
98
84
|
|
99
85
|
destroy_timer(data);
|
86
|
+
data->timer_id = 0;
|
100
87
|
create_new_timer(data);
|
101
88
|
|
102
89
|
return self;
|
103
90
|
}
|
104
91
|
|
92
|
+
/* call-seq:
|
93
|
+
* Posix::Timer.new
|
94
|
+
* Posix::Timer.new("ALRM")
|
95
|
+
* Posix::Timer.new("USR1")
|
96
|
+
* Posix::Timer.new { some_block }
|
97
|
+
*
|
98
|
+
* Create a new Posix::Timer object. The argument passed can be any valid
|
99
|
+
* signal type from Signal.list.
|
100
|
+
*
|
101
|
+
* If a block is passed, that block will be executed when the Posix::Timer timeout
|
102
|
+
* has expired. This is done by trapping the signal specified as creation time, so
|
103
|
+
* be careful if you have other uses of that signal in your program.
|
104
|
+
*
|
105
|
+
*/
|
105
106
|
static VALUE timer_new(int argc, VALUE *argv, VALUE self)
|
106
107
|
{
|
107
108
|
VALUE obj = rb_funcall(self, rb_intern("allocate"), 0);
|
@@ -141,6 +142,9 @@ static VALUE timer_arm(VALUE klass, VALUE arg)
|
|
141
142
|
|
142
143
|
data->tspec.it_value.tv_sec = sec;
|
143
144
|
data->tspec.it_value.tv_nsec = usec;
|
145
|
+
// Set the interval to 0 for timer resets
|
146
|
+
data->tspec.it_interval.tv_sec = 0;
|
147
|
+
data->tspec.it_interval.tv_nsec = 0;
|
144
148
|
|
145
149
|
if(timer_settime(data->timer_id, 0, &(data->tspec), NULL) == -1)
|
146
150
|
rb_sys_fail("timer_settime()");
|
data/test/timertests.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
!ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: posixtimer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date:
|
6
|
+
version: "0.2"
|
7
|
+
date: 2006-02-09 00:00:00 -05:00
|
8
8
|
summary: A class that provides a definable timeout
|
9
9
|
require_paths:
|
10
10
|
- .
|