Sha256: 82c774c8f066451a664fc6080b9ee4c7b28e68dee5c6f02c67202c6b75a9ca42

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

#include <ruby.h>

#include "atomic_boolean.h"
#include "atomic_reference.h"

void atomic_boolean_mark(void *value) {
  rb_gc_mark_maybe((VALUE) value);
}

VALUE atomic_boolean_allocate(VALUE klass) {
  return rb_data_object_alloc(klass, (void *) Qfalse, atomic_boolean_mark, NULL);
}

VALUE method_atomic_boolean_initialize(int argc, VALUE* argv, VALUE self) {
  VALUE value = Qfalse;
  rb_check_arity(argc, 0, 1);
  if (argc == 1) value = TRUTHY(argv[0]);
  DATA_PTR(self) = (void *) value;
  return(self);
}

VALUE method_atomic_boolean_value(VALUE self) {
  return(ir_get(self));
}

VALUE method_atomic_boolean_value_set(VALUE self, VALUE value) {
  VALUE new_value = TRUTHY(value);
  return(ir_set(self, new_value));
}

VALUE method_atomic_boolean_true_question(VALUE self) {
  return(method_atomic_boolean_value(self));
}

VALUE method_atomic_boolean_false_question(VALUE self) {
  VALUE current = method_atomic_boolean_value(self);
  return(current == Qfalse ? Qtrue : Qfalse);
}

VALUE method_atomic_boolean_make_true(VALUE self) {
  return(ir_compare_and_set(self, Qfalse, Qtrue));
}

VALUE method_atomic_boolean_make_false(VALUE self) {
  return(ir_compare_and_set(self, Qtrue, Qfalse));
}

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
o-concurrent-ruby-ext-1.1.13 ext/concurrent-ruby-ext/atomic_boolean.c
o-concurrent-ruby-ext-1.1.12 ext/concurrent-ruby-ext/atomic_boolean.c
o-concurrent-ruby-ext-1.1.11 ext/concurrent-ruby-ext/atomic_boolean.c
concurrent-ruby-ext-1.1.10-x86-mingw32 ext/concurrent-ruby-ext/atomic_boolean.c
concurrent-ruby-ext-1.1.10-x64-mingw32 ext/concurrent-ruby-ext/atomic_boolean.c
concurrent-ruby-ext-1.1.10 ext/concurrent-ruby-ext/atomic_boolean.c