Module: ConcurrentSHM
- Defined in:
- lib/concurrent-shm/gem.rb,
lib/concurrent-shm/channel.rb,
lib/concurrent-shm/int_ptr.rb,
ext/concurrent-shm/main.c
Overview
Shared Memory Concurrency
Defined Under Namespace
Modules: Gem, Value Classes: Channel, Condition, Mutex, Region, SharedMemory
Class Method Summary collapse
-
.size_of(type) ⇒ Object
Calculate the number of shared memory space bytes required by instances of the specified class.
Class Method Details
.size_of(type) ⇒ Object
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'ext/concurrent-shm/posix.c', line 749
static VALUE size_of(VALUE self, VALUE type)
{
UNUSED(self);
if (!RB_TYPE_P(type, T_CLASS)) {
rb_raise(rb_eArgError, "Expected a class");
}
size_t s;
if (type == Mutex) {
s = sizeof(struct mutex_shared);
} else if (type == Condition) {
s = sizeof(struct condition_shared);
} else {
rb_raise(rb_eArgError, "Unrecognized type");
}
size_t o = s % 16;
if (o) {
s += 16-o;
}
return INT2FIX(s);
}
|