Method: Thread#thread_variable_set
- Defined in:
- thread.c
#thread_variable_set(key, value) ⇒ Object
Sets a thread local with key
to value
. Note that these are local to threads, and not to fibers. Please see Thread#thread_variable_get and Thread#[] for more information.
3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 |
# File 'thread.c', line 3683
static VALUE
rb_thread_variable_set(VALUE thread, VALUE key, VALUE val)
{
VALUE locals;
if (OBJ_FROZEN(thread)) {
rb_frozen_error_raise(thread, "can't modify frozen thread locals");
}
locals = rb_thread_local_storage(thread);
return rb_hash_aset(locals, rb_to_symbol(key), val);
}
|