Skip to content

Commit 978eed6

Browse files
nobueregon
authored andcommitted
Use typed data APIs
1 parent eacd77a commit 978eed6

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

ext/concurrent-ruby-ext/atomic_boolean.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ void atomic_boolean_mark(void *value) {
77
rb_gc_mark_maybe((VALUE) value);
88
}
99

10+
const rb_data_type_t atomic_boolean_type = {
11+
"Concurrent::CAtomicBoolean",
12+
{
13+
atomic_boolean_mark,
14+
RUBY_NEVER_FREE,
15+
},
16+
};
17+
1018
VALUE atomic_boolean_allocate(VALUE klass) {
11-
return rb_data_object_wrap(klass, (void *) Qfalse, atomic_boolean_mark, NULL);
19+
return rb_data_typed_object_wrap(klass, (void *) Qfalse, &atomic_boolean_type);
1220
}
1321

1422
VALUE method_atomic_boolean_initialize(int argc, VALUE* argv, VALUE self) {

ext/concurrent-ruby-ext/atomic_fixnum.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ void atomic_fixnum_mark(void *value) {
77
rb_gc_mark_maybe((VALUE) value);
88
}
99

10+
const rb_data_type_t atomic_fixnum_type = {
11+
"Concurrent::CAtomicFixnum",
12+
{
13+
atomic_fixnum_mark,
14+
RUBY_NEVER_FREE,
15+
},
16+
};
17+
1018
VALUE atomic_fixnum_allocate(VALUE klass) {
11-
return rb_data_object_wrap(klass, (void *) Qnil, atomic_fixnum_mark, NULL);
19+
return rb_data_typed_object_wrap(klass, (void *) Qnil, &atomic_fixnum_type);
1220
}
1321

1422
VALUE method_atomic_fixnum_initialize(int argc, VALUE* argv, VALUE self) {

ext/concurrent-ruby-ext/atomic_reference.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@ void ir_mark(void *value) {
4343
rb_gc_mark_maybe((VALUE) value);
4444
}
4545

46+
const rb_data_type_t ir_type = {
47+
"Concurrent::CAtomicReference",
48+
{
49+
ir_mark,
50+
RUBY_NEVER_FREE,
51+
},
52+
};
53+
4654
VALUE ir_alloc(VALUE klass) {
47-
return rb_data_object_wrap(klass, (void *) Qnil, ir_mark, NULL);
55+
return rb_data_typed_object_wrap(klass, (void *) Qnil, &ir_type);
4856
}
4957

5058
VALUE ir_initialize(int argc, VALUE* argv, VALUE self) {

0 commit comments

Comments
 (0)