xthread 0.1.3 → 0.1.4.001
Sign up to get free protection for your applications and to get access to all the features.
- data/cond.c +9 -0
- data/fifo.c +18 -5
- data/monitor.c +18 -0
- data/queue.c +14 -3
- data/xthread.gemspec +10 -2
- metadata +6 -5
data/cond.c
CHANGED
@@ -43,10 +43,19 @@ xthread_cond_memsize(const void *ptr)
|
|
43
43
|
return ptr ? sizeof(xthread_cond_t) : 0;
|
44
44
|
}
|
45
45
|
|
46
|
+
#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION
|
46
47
|
static const rb_data_type_t xthread_cond_data_type = {
|
47
48
|
"xthread_cond",
|
48
49
|
{xthread_cond_mark, xthread_cond_free, xthread_cond_memsize,},
|
49
50
|
};
|
51
|
+
#else
|
52
|
+
static const rb_data_type_t xthread_cond_data_type = {
|
53
|
+
"xthread_cond",
|
54
|
+
xthread_cond_mark,
|
55
|
+
xthread_cond_free,
|
56
|
+
xthread_cond_memsize,
|
57
|
+
};
|
58
|
+
#endif
|
50
59
|
|
51
60
|
static VALUE
|
52
61
|
xthread_cond_alloc(VALUE klass)
|
data/fifo.c
CHANGED
@@ -55,8 +55,10 @@ static void
|
|
55
55
|
xthread_fifo_free(void *ptr)
|
56
56
|
{
|
57
57
|
xthread_fifo_t *fifo = (xthread_fifo_t*)ptr;
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
if (fifo->elements) {
|
60
|
+
ruby_xfree(fifo->elements);
|
61
|
+
}
|
60
62
|
ruby_xfree(ptr);
|
61
63
|
}
|
62
64
|
|
@@ -68,10 +70,19 @@ xthread_fifo_memsize(const void *ptr)
|
|
68
70
|
return ptr ? sizeof(xthread_fifo_t) + fifo->capa * sizeof(VALUE): 0;
|
69
71
|
}
|
70
72
|
|
73
|
+
#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION
|
71
74
|
static const rb_data_type_t xthread_fifo_data_type = {
|
72
75
|
"xthread_fifo",
|
73
76
|
{xthread_fifo_mark, xthread_fifo_free, xthread_fifo_memsize,},
|
74
77
|
};
|
78
|
+
#else
|
79
|
+
static const rb_data_type_t xthread_fifo_data_type = {
|
80
|
+
"xthread_fifo",
|
81
|
+
xthread_fifo_mark,
|
82
|
+
xthread_fifo_free,
|
83
|
+
xthread_fifo_memsize,
|
84
|
+
};
|
85
|
+
#endif
|
75
86
|
|
76
87
|
static VALUE
|
77
88
|
xthread_fifo_alloc(VALUE klass)
|
@@ -84,7 +95,7 @@ xthread_fifo_alloc(VALUE klass)
|
|
84
95
|
fifo->push = 0;
|
85
96
|
fifo->pop = 0;
|
86
97
|
|
87
|
-
fifo->capa =
|
98
|
+
fifo->capa = 0;
|
88
99
|
fifo->elements = NULL;
|
89
100
|
|
90
101
|
return obj;
|
@@ -117,7 +128,8 @@ xthread_fifo_initialize(VALUE self)
|
|
117
128
|
{
|
118
129
|
xthread_fifo_t *fifo;
|
119
130
|
GetXThreadFifoPtr(self, fifo);
|
120
|
-
|
131
|
+
|
132
|
+
fifo->capa = FIFO_DEFAULT_CAPA;
|
121
133
|
fifo->elements = ALLOC_N(VALUE, fifo->capa);
|
122
134
|
return self;
|
123
135
|
}
|
@@ -165,7 +177,8 @@ rb_xthread_fifo_pop(VALUE self)
|
|
165
177
|
if (fifo->push == fifo->pop)
|
166
178
|
return Qnil;
|
167
179
|
|
168
|
-
item = fifo->elements[fifo->pop
|
180
|
+
item = fifo->elements[fifo->pop];
|
181
|
+
fifo->elements[fifo->pop++] = Qnil;
|
169
182
|
if(fifo->pop >= fifo->capa) {
|
170
183
|
fifo->pop -= fifo->capa;
|
171
184
|
fifo->push -= fifo->capa;
|
data/monitor.c
CHANGED
@@ -56,10 +56,19 @@ xthread_monitor_memsize(const void *ptr)
|
|
56
56
|
return ptr ? sizeof(xthread_monitor_t) : 0;
|
57
57
|
}
|
58
58
|
|
59
|
+
#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION
|
59
60
|
static const rb_data_type_t xthread_monitor_data_type = {
|
60
61
|
"xthread_monitor",
|
61
62
|
{xthread_monitor_mark, xthread_monitor_free, xthread_monitor_memsize,},
|
62
63
|
};
|
64
|
+
#else
|
65
|
+
static const rb_data_type_t xthread_monitor_data_type = {
|
66
|
+
"xthread_monitor",
|
67
|
+
xthread_monitor_mark,
|
68
|
+
xthread_monitor_free,
|
69
|
+
xthread_monitor_memsize,
|
70
|
+
};
|
71
|
+
#endif
|
63
72
|
|
64
73
|
static VALUE
|
65
74
|
xthread_monitor_alloc(VALUE klass)
|
@@ -243,10 +252,19 @@ xthread_monitor_cond_memsize(const void *ptr)
|
|
243
252
|
return ptr ? sizeof(xthread_monitor_cond_t) : 0;
|
244
253
|
}
|
245
254
|
|
255
|
+
#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION
|
246
256
|
static const rb_data_type_t xthread_monitor_cond_data_type = {
|
247
257
|
"xthread_monitor_cond",
|
248
258
|
{xthread_monitor_cond_mark, xthread_monitor_cond_free, xthread_monitor_cond_memsize,},
|
249
259
|
};
|
260
|
+
#else
|
261
|
+
static const rb_data_type_t xthread_monitor_cond_data_type = {
|
262
|
+
"xthread_monitor_cond",
|
263
|
+
xthread_monitor_cond_mark,
|
264
|
+
xthread_monitor_cond_free,
|
265
|
+
xthread_monitor_cond_memsize,
|
266
|
+
};
|
267
|
+
#endif
|
250
268
|
|
251
269
|
static VALUE
|
252
270
|
xthread_monitor_cond_alloc(VALUE klass)
|
data/queue.c
CHANGED
@@ -49,10 +49,19 @@ xthread_queue_memsize(const void *ptr)
|
|
49
49
|
return ptr ? sizeof(xthread_queue_t) : 0;
|
50
50
|
}
|
51
51
|
|
52
|
+
#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION
|
52
53
|
static const rb_data_type_t xthread_queue_data_type = {
|
53
54
|
"xthread_queue",
|
54
55
|
{xthread_queue_mark, xthread_queue_free, xthread_queue_memsize,},
|
55
56
|
};
|
57
|
+
#else
|
58
|
+
static const rb_data_type_t xthread_queue_data_type = {
|
59
|
+
"xthread_queue",
|
60
|
+
xthread_queue_mark,
|
61
|
+
xthread_queue_free,
|
62
|
+
xthread_queue_memsize,
|
63
|
+
};
|
64
|
+
#endif
|
56
65
|
|
57
66
|
static void
|
58
67
|
xthread_queue_alloc_init(xthread_queue_t *que)
|
@@ -217,6 +226,8 @@ xthread_sized_queue_memsize(const void *ptr)
|
|
217
226
|
return ptr ? sizeof(xthread_sized_queue_t) : 0;
|
218
227
|
}
|
219
228
|
|
229
|
+
|
230
|
+
#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION
|
220
231
|
static const rb_data_type_t xthread_sized_queue_data_type = {
|
221
232
|
"xthread_sized_queue",
|
222
233
|
{xthread_sized_queue_mark, xthread_sized_queue_free, xthread_sized_queue_memsize,},
|
@@ -355,6 +366,7 @@ xthread_sized_queue_pop(int argc, VALUE *argv, VALUE self)
|
|
355
366
|
}
|
356
367
|
return item;
|
357
368
|
}
|
369
|
+
#endif
|
358
370
|
|
359
371
|
void
|
360
372
|
Init_XThreadQueue()
|
@@ -374,7 +386,7 @@ Init_XThreadQueue()
|
|
374
386
|
rb_define_method(rb_cXThreadQueue, "length", rb_xthread_queue_length, 0);
|
375
387
|
rb_define_alias(rb_cXThreadQueue, "size", "length");
|
376
388
|
|
377
|
-
|
389
|
+
#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION
|
378
390
|
rb_cXThreadSizedQueue = rb_define_class_under(rb_mXThread, "SizedQueue", rb_cXThreadQueue);
|
379
391
|
|
380
392
|
rb_define_alloc_func(rb_cXThreadSizedQueue, xthread_sized_queue_alloc);
|
@@ -388,6 +400,5 @@ Init_XThreadQueue()
|
|
388
400
|
|
389
401
|
rb_define_method(rb_cXThreadSizedQueue, "max", rb_xthread_sized_queue_max, 0);
|
390
402
|
rb_define_method(rb_cXThreadSizedQueue, "max=", rb_xthread_sized_queue_set_max, 1);
|
391
|
-
|
392
|
-
|
403
|
+
#endif
|
393
404
|
}
|
data/xthread.gemspec
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
|
2
2
|
require "rubygems"
|
3
3
|
|
4
|
+
tag = `git tag`.split.sort.last
|
5
|
+
v, dmy, p = tag.scan(/^v([0-9]+\.[0-9]+\.[0-9]+)(-([0-9]+))?/).first
|
6
|
+
if p.to_i > 0
|
7
|
+
v += "."+p
|
8
|
+
end
|
9
|
+
p v
|
10
|
+
|
4
11
|
Gem::Specification.new do |s|
|
5
12
|
s.name = "xthread"
|
6
13
|
s.authors = "Keiju.Ishitsuka"
|
7
14
|
s.email = "keiju@ishitsuka.com"
|
8
15
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.summary = "C-implementation version of thread.rb and monitor.
|
16
|
+
s.summary = "C-implementation version of thread.rb and monitor.rb libraries"
|
10
17
|
s.rubyforge_project = s.name
|
11
18
|
s.homepage = "http://github.com/keiju/xthread"
|
12
|
-
|
19
|
+
|
20
|
+
s.version = v
|
13
21
|
s.require_path = "."
|
14
22
|
# s.test_file = ""
|
15
23
|
# s.executable = ""
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xthread
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 85
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
|
9
|
+
- 4
|
10
|
+
- 1
|
11
|
+
version: 0.1.4.001
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Keiju.Ishitsuka
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-04-
|
19
|
+
date: 2011-04-19 00:00:00 +09:00
|
19
20
|
default_executable:
|
20
21
|
dependencies: []
|
21
22
|
|
@@ -74,6 +75,6 @@ rubyforge_project: xthread
|
|
74
75
|
rubygems_version: 1.3.7
|
75
76
|
signing_key:
|
76
77
|
specification_version: 3
|
77
|
-
summary: C-implementation version of thread.rb and monitor.
|
78
|
+
summary: C-implementation version of thread.rb and monitor.rb libraries
|
78
79
|
test_files: []
|
79
80
|
|