зеркало из https://github.com/github/ruby.git
fix public interface
To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
This commit is contained in:
Родитель
0683912db8
Коммит
5e3259ea74
28
common.mk
28
common.mk
|
@ -3372,7 +3372,7 @@ cont.$(OBJEXT): {$(VPATH)}missing.h
|
|||
cont.$(OBJEXT): {$(VPATH)}mjit.h
|
||||
cont.$(OBJEXT): {$(VPATH)}node.h
|
||||
cont.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
cont.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
cont.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
cont.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
cont.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
cont.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -3566,7 +3566,7 @@ debug.$(OBJEXT): {$(VPATH)}node.h
|
|||
debug.$(OBJEXT): {$(VPATH)}onigmo.h
|
||||
debug.$(OBJEXT): {$(VPATH)}oniguruma.h
|
||||
debug.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
debug.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
debug.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
debug.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
debug.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
debug.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -4622,7 +4622,6 @@ encoding.$(OBJEXT): {$(VPATH)}missing.h
|
|||
encoding.$(OBJEXT): {$(VPATH)}node.h
|
||||
encoding.$(OBJEXT): {$(VPATH)}onigmo.h
|
||||
encoding.$(OBJEXT): {$(VPATH)}oniguruma.h
|
||||
encoding.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
encoding.$(OBJEXT): {$(VPATH)}regenc.h
|
||||
encoding.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
encoding.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -5402,7 +5401,7 @@ eval.$(OBJEXT): {$(VPATH)}probes.dmyh
|
|||
eval.$(OBJEXT): {$(VPATH)}probes.h
|
||||
eval.$(OBJEXT): {$(VPATH)}probes_helper.h
|
||||
eval.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
eval.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
eval.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
eval.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
eval.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
eval.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -5824,7 +5823,7 @@ gc.$(OBJEXT): {$(VPATH)}oniguruma.h
|
|||
gc.$(OBJEXT): {$(VPATH)}probes.dmyh
|
||||
gc.$(OBJEXT): {$(VPATH)}probes.h
|
||||
gc.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
gc.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
gc.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
gc.$(OBJEXT): {$(VPATH)}re.h
|
||||
gc.$(OBJEXT): {$(VPATH)}regenc.h
|
||||
gc.$(OBJEXT): {$(VPATH)}regex.h
|
||||
|
@ -6744,7 +6743,7 @@ io.$(OBJEXT): {$(VPATH)}missing.h
|
|||
io.$(OBJEXT): {$(VPATH)}node.h
|
||||
io.$(OBJEXT): {$(VPATH)}onigmo.h
|
||||
io.$(OBJEXT): {$(VPATH)}oniguruma.h
|
||||
io.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
io.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
io.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
io.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
io.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -9756,7 +9755,7 @@ parse.$(OBJEXT): {$(VPATH)}parse.h
|
|||
parse.$(OBJEXT): {$(VPATH)}parse.y
|
||||
parse.$(OBJEXT): {$(VPATH)}probes.dmyh
|
||||
parse.$(OBJEXT): {$(VPATH)}probes.h
|
||||
parse.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
parse.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
parse.$(OBJEXT): {$(VPATH)}regenc.h
|
||||
parse.$(OBJEXT): {$(VPATH)}regex.h
|
||||
parse.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
|
@ -10179,7 +10178,7 @@ process.$(OBJEXT): {$(VPATH)}node.h
|
|||
process.$(OBJEXT): {$(VPATH)}onigmo.h
|
||||
process.$(OBJEXT): {$(VPATH)}oniguruma.h
|
||||
process.$(OBJEXT): {$(VPATH)}process.c
|
||||
process.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
process.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
process.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
process.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
process.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -10384,7 +10383,7 @@ ractor.$(OBJEXT): {$(VPATH)}ractor.c
|
|||
ractor.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
ractor.$(OBJEXT): {$(VPATH)}ractor.rb
|
||||
ractor.$(OBJEXT): {$(VPATH)}ractor.rbinc
|
||||
ractor.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
ractor.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
ractor.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
ractor.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
ractor.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -14180,7 +14179,7 @@ thread.$(OBJEXT): {$(VPATH)}node.h
|
|||
thread.$(OBJEXT): {$(VPATH)}onigmo.h
|
||||
thread.$(OBJEXT): {$(VPATH)}oniguruma.h
|
||||
thread.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
thread.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
thread.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
thread.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
thread.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
thread.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -14738,7 +14737,6 @@ transient_heap.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
|
|||
transient_heap.$(OBJEXT): {$(VPATH)}method.h
|
||||
transient_heap.$(OBJEXT): {$(VPATH)}missing.h
|
||||
transient_heap.$(OBJEXT): {$(VPATH)}node.h
|
||||
transient_heap.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
transient_heap.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
transient_heap.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
transient_heap.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -15106,7 +15104,7 @@ variable.$(OBJEXT): {$(VPATH)}node.h
|
|||
variable.$(OBJEXT): {$(VPATH)}onigmo.h
|
||||
variable.$(OBJEXT): {$(VPATH)}oniguruma.h
|
||||
variable.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
variable.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
variable.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
variable.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
variable.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
variable.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -15520,7 +15518,7 @@ vm.$(OBJEXT): {$(VPATH)}probes.dmyh
|
|||
vm.$(OBJEXT): {$(VPATH)}probes.h
|
||||
vm.$(OBJEXT): {$(VPATH)}probes_helper.h
|
||||
vm.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
vm.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
vm.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
vm.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
vm.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
vm.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -15912,7 +15910,7 @@ vm_dump.$(OBJEXT): {$(VPATH)}missing.h
|
|||
vm_dump.$(OBJEXT): {$(VPATH)}node.h
|
||||
vm_dump.$(OBJEXT): {$(VPATH)}procstat_vm.c
|
||||
vm_dump.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
vm_dump.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
vm_dump.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
vm_dump.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
vm_dump.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
vm_dump.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
@ -16108,7 +16106,7 @@ vm_sync.$(OBJEXT): {$(VPATH)}missing.h
|
|||
vm_sync.$(OBJEXT): {$(VPATH)}node.h
|
||||
vm_sync.$(OBJEXT): {$(VPATH)}procstat_vm.c
|
||||
vm_sync.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
vm_sync.$(OBJEXT): {$(VPATH)}ractor_pub.h
|
||||
vm_sync.$(OBJEXT): {$(VPATH)}ractor_core.h
|
||||
vm_sync.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
vm_sync.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
vm_sync.$(OBJEXT): {$(VPATH)}st.h
|
||||
|
|
2
cont.c
2
cont.c
|
@ -29,7 +29,7 @@
|
|||
#include "mjit.h"
|
||||
#include "vm_core.h"
|
||||
#include "id_table.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
|
||||
static const int DEBUG = 0;
|
||||
|
||||
|
|
2
debug.c
2
debug.c
|
@ -26,7 +26,7 @@
|
|||
#include "vm_debug.h"
|
||||
#include "vm_callinfo.h"
|
||||
#include "ruby/thread_native.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
|
||||
/* This is the only place struct RIMemo is actually used */
|
||||
struct RIMemo {
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "ruby/encoding.h"
|
||||
#include "ruby/util.h"
|
||||
#include "ruby_assert.h"
|
||||
#include "ractor_pub.h"
|
||||
#include "vm_sync.h"
|
||||
|
||||
#ifndef ENC_DEBUG
|
||||
|
|
2
eval.c
2
eval.c
|
@ -37,7 +37,7 @@
|
|||
#include "probes_helper.h"
|
||||
#include "ruby/vm.h"
|
||||
#include "vm_core.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
|
||||
NORETURN(void rb_raise_jump(VALUE, VALUE));
|
||||
void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec);
|
||||
|
|
|
@ -210,6 +210,7 @@ ripper.o: $(hdrdir)/ruby/io.h
|
|||
ripper.o: $(hdrdir)/ruby/missing.h
|
||||
ripper.o: $(hdrdir)/ruby/onigmo.h
|
||||
ripper.o: $(hdrdir)/ruby/oniguruma.h
|
||||
ripper.o: $(hdrdir)/ruby/ractor.h
|
||||
ripper.o: $(hdrdir)/ruby/regex.h
|
||||
ripper.o: $(hdrdir)/ruby/ruby.h
|
||||
ripper.o: $(hdrdir)/ruby/st.h
|
||||
|
@ -244,7 +245,6 @@ ripper.o: $(top_srcdir)/internal/variable.h
|
|||
ripper.o: $(top_srcdir)/internal/vm.h
|
||||
ripper.o: $(top_srcdir)/internal/warnings.h
|
||||
ripper.o: $(top_srcdir)/node.h
|
||||
ripper.o: $(top_srcdir)/ractor_pub.h
|
||||
ripper.o: $(top_srcdir)/regenc.h
|
||||
ripper.o: $(top_srcdir)/ruby_assert.h
|
||||
ripper.o: $(top_srcdir)/symbol.h
|
||||
|
|
2
gc.c
2
gc.c
|
@ -112,7 +112,7 @@
|
|||
#include "vm_core.h"
|
||||
#include "vm_sync.h"
|
||||
#include "vm_callinfo.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
|
||||
#include "builtin.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef RUBY_RACTOR_H
|
||||
#define RUBY_RACTOR_H 1
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @author Koichi Sasada
|
||||
* @date Tue Nov 17 16:39:15 2020
|
||||
* @copyright Copyright (C) 2020 Yukihiro Matsumoto
|
||||
* @copyright This file is a part of the programming language Ruby.
|
||||
* Permission is hereby granted, to either redistribute and/or
|
||||
* modify this file, provided that the conditions mentioned in the
|
||||
* file COPYING are met. Consult the file for details.
|
||||
*/
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
RUBY_EXTERN VALUE rb_cRactor;
|
||||
|
||||
VALUE rb_ractor_stdin(void);
|
||||
VALUE rb_ractor_stdout(void);
|
||||
VALUE rb_ractor_stderr(void);
|
||||
void rb_ractor_stdin_set(VALUE);
|
||||
void rb_ractor_stdout_set(VALUE);
|
||||
void rb_ractor_stderr_set(VALUE);
|
||||
|
||||
bool rb_ractor_shareable_p_continue(VALUE obj); // do not call it directly.
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#define RB_OBJ_SHAREABLE_P(obj) FL_TEST_RAW((obj), RUBY_FL_SHAREABLE)
|
||||
|
||||
static inline bool
|
||||
rb_ractor_shareable_p(VALUE obj)
|
||||
{
|
||||
if (SPECIAL_CONST_P(obj)) {
|
||||
return true;
|
||||
}
|
||||
else if (RB_OBJ_SHAREABLE_P(obj)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return rb_ractor_shareable_p_continue(obj);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* RUBY_RACTOR_H */
|
|
@ -31,10 +31,14 @@ typedef union rb_thread_lock_union {
|
|||
CRITICAL_SECTION crit;
|
||||
} rb_nativethread_lock_t;
|
||||
|
||||
typedef struct rb_thread_cond_struct rb_nativethread_cond_t;
|
||||
|
||||
#elif defined(HAVE_PTHREAD_H)
|
||||
|
||||
#include <pthread.h>
|
||||
typedef pthread_t rb_nativethread_id_t;
|
||||
typedef pthread_mutex_t rb_nativethread_lock_t;
|
||||
typedef pthread_cond_t rb_nativethread_cond_t;
|
||||
|
||||
#else
|
||||
#error "unsupported thread type"
|
||||
|
@ -50,6 +54,19 @@ void rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock);
|
|||
void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock);
|
||||
void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock);
|
||||
|
||||
void rb_native_mutex_lock(rb_nativethread_lock_t *lock);
|
||||
int rb_native_mutex_trylock(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_unlock(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_initialize(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_destroy(rb_nativethread_lock_t *lock);
|
||||
|
||||
void rb_native_cond_signal(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_broadcast(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_wait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex);
|
||||
void rb_native_cond_timedwait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex, unsigned long msec);
|
||||
void rb_native_cond_initialize(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_destroy(rb_nativethread_cond_t *cond);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#endif
|
||||
|
|
2
io.c
2
io.c
|
@ -134,7 +134,7 @@
|
|||
#include "ruby/thread.h"
|
||||
#include "ruby/util.h"
|
||||
#include "ruby_atomic.h"
|
||||
#include "ractor_pub.h"
|
||||
#include "ruby/ractor.h"
|
||||
|
||||
#if !USE_POLL
|
||||
# include "vm_core.h"
|
||||
|
|
2
parse.y
2
parse.y
|
@ -57,8 +57,8 @@ struct lex_context {
|
|||
#include "ruby/ruby.h"
|
||||
#include "ruby/st.h"
|
||||
#include "ruby/util.h"
|
||||
#include "ruby/ractor.h"
|
||||
#include "symbol.h"
|
||||
#include "ractor_pub.h"
|
||||
|
||||
#define AREF(ary, i) RARRAY_AREF(ary, i)
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ int initgroups(const char *, rb_gid_t);
|
|||
#include "ruby/thread.h"
|
||||
#include "ruby/util.h"
|
||||
#include "vm_core.h"
|
||||
#include "ractor_pub.h"
|
||||
#include "ruby/ractor.h"
|
||||
|
||||
/* define system APIs */
|
||||
#ifdef _WIN32
|
||||
|
|
5
ractor.c
5
ractor.c
|
@ -2,10 +2,11 @@
|
|||
|
||||
#include "ruby/ruby.h"
|
||||
#include "ruby/thread.h"
|
||||
#include "ruby/ractor.h"
|
||||
#include "ruby/thread_native.h"
|
||||
#include "vm_core.h"
|
||||
#include "vm_sync.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
#include "internal/complex.h"
|
||||
#include "internal/error.h"
|
||||
#include "internal/hash.h"
|
||||
|
@ -14,7 +15,7 @@
|
|||
#include "variable.h"
|
||||
#include "gc.h"
|
||||
|
||||
static VALUE rb_cRactor;
|
||||
VALUE rb_cRactor;
|
||||
static VALUE rb_eRactorError;
|
||||
static VALUE rb_eRactorRemoteError;
|
||||
static VALUE rb_eRactorMovedError;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "ruby/ruby.h"
|
||||
#include "ruby/ractor.h"
|
||||
#include "vm_core.h"
|
||||
#include "id_table.h"
|
||||
#include "vm_debug.h"
|
||||
#include "ractor_pub.h"
|
||||
|
||||
#ifndef RACTOR_CHECK_MODE
|
||||
#define RACTOR_CHECK_MODE (0 || VM_CHECK_MODE || RUBY_DEBUG)
|
||||
|
@ -158,6 +158,20 @@ void rb_ractor_blocking_threads_dec(rb_ractor_t *r, const char *file, int line);
|
|||
void rb_ractor_vm_barrier_interrupt_running_thread(rb_ractor_t *r);
|
||||
void rb_ractor_terminate_interrupt_main_thread(rb_ractor_t *r);
|
||||
void rb_ractor_terminate_all(void);
|
||||
bool rb_ractor_main_p_(void);
|
||||
|
||||
RUBY_EXTERN bool ruby_multi_ractor;
|
||||
|
||||
static inline bool
|
||||
rb_ractor_main_p(void)
|
||||
{
|
||||
if (!ruby_multi_ractor) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return rb_ractor_main_p_();
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
rb_ractor_status_p(rb_ractor_t *r, enum ractor_status status)
|
52
ractor_pub.h
52
ractor_pub.h
|
@ -1,52 +0,0 @@
|
|||
#ifndef RACTOR_PUB_INCLUDED
|
||||
#define RACTOR_PUB_INCLUDED
|
||||
|
||||
RUBY_EXTERN bool ruby_multi_ractor;
|
||||
|
||||
bool rb_ractor_main_p_(void);
|
||||
|
||||
static inline bool
|
||||
rb_ractor_main_p(void)
|
||||
{
|
||||
if (!ruby_multi_ractor) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return rb_ractor_main_p_();
|
||||
}
|
||||
}
|
||||
|
||||
bool rb_ractor_shareable_p_continue(VALUE obj);
|
||||
|
||||
#define RB_OBJ_SHAREABLE_P(obj) FL_TEST_RAW((obj), RUBY_FL_SHAREABLE)
|
||||
|
||||
// TODO: deep frozen
|
||||
|
||||
static inline bool
|
||||
rb_ractor_shareable_p(VALUE obj)
|
||||
{
|
||||
if (SPECIAL_CONST_P(obj)) {
|
||||
return true;
|
||||
}
|
||||
else if (RB_OBJ_SHAREABLE_P(obj)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return rb_ractor_shareable_p_continue(obj);
|
||||
}
|
||||
}
|
||||
|
||||
VALUE rb_ractor_make_shareable(VALUE obj);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
|
||||
VALUE rb_ractor_stdin(void);
|
||||
VALUE rb_ractor_stdout(void);
|
||||
VALUE rb_ractor_stderr(void);
|
||||
void rb_ractor_stdin_set(VALUE);
|
||||
void rb_ractor_stdout_set(VALUE);
|
||||
void rb_ractor_stderr_set(VALUE);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#endif
|
2
thread.c
2
thread.c
|
@ -94,7 +94,7 @@
|
|||
#include "ruby/thread_native.h"
|
||||
#include "timev.h"
|
||||
#include "vm_core.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
#include "vm_debug.h"
|
||||
#include "vm_sync.h"
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#define RB_NATIVETHREAD_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
|
||||
#define RB_NATIVETHREAD_COND_INIT PTHREAD_COND_INITIALIZER
|
||||
|
||||
typedef pthread_cond_t rb_nativethread_cond_t;
|
||||
|
||||
typedef struct native_thread_data_struct {
|
||||
union {
|
||||
struct list_node ubf;
|
||||
|
@ -39,18 +37,6 @@ typedef struct native_thread_data_struct {
|
|||
} cond;
|
||||
} native_thread_data_t;
|
||||
|
||||
void rb_native_mutex_lock(rb_nativethread_lock_t *lock);
|
||||
int rb_native_mutex_trylock(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_unlock(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_initialize(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_destroy(rb_nativethread_lock_t *lock);
|
||||
void rb_native_cond_signal(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_broadcast(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_wait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex);
|
||||
void rb_native_cond_timedwait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex, unsigned long msec);
|
||||
void rb_native_cond_initialize(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_destroy(rb_nativethread_cond_t *cond);
|
||||
|
||||
#undef except
|
||||
#undef try
|
||||
#undef leave
|
||||
|
|
|
@ -52,12 +52,12 @@ w32_error(const char *func)
|
|||
}
|
||||
|
||||
static int
|
||||
w32_mutex_lock(HANDLE lock)
|
||||
w32_mutex_lock(HANDLE lock, bool try)
|
||||
{
|
||||
DWORD result;
|
||||
while (1) {
|
||||
thread_debug("rb_native_mutex_lock: %p\n", lock);
|
||||
result = w32_wait_events(&lock, 1, INFINITE, 0);
|
||||
result = w32_wait_events(&lock, 1, try ? 0 : INFINITE, 0);
|
||||
switch (result) {
|
||||
case WAIT_OBJECT_0:
|
||||
/* get mutex object */
|
||||
|
@ -70,7 +70,7 @@ w32_mutex_lock(HANDLE lock)
|
|||
return 0;
|
||||
case WAIT_TIMEOUT:
|
||||
thread_debug("timeout mutex: %p\n", lock);
|
||||
break;
|
||||
return EBUSY;
|
||||
case WAIT_ABANDONED:
|
||||
rb_bug("win32_mutex_lock: WAIT_ABANDONED");
|
||||
break;
|
||||
|
@ -97,7 +97,7 @@ w32_mutex_create(void)
|
|||
static void
|
||||
gvl_acquire(rb_global_vm_lock_t *gvl, rb_thread_t *th)
|
||||
{
|
||||
w32_mutex_lock(gvl->lock);
|
||||
w32_mutex_lock(gvl->lock, false);
|
||||
if (GVL_DEBUG) fprintf(stderr, "gvl acquire (%p): acquire\n", th);
|
||||
}
|
||||
|
||||
|
@ -323,12 +323,22 @@ void
|
|||
rb_native_mutex_lock(rb_nativethread_lock_t *lock)
|
||||
{
|
||||
#if USE_WIN32_MUTEX
|
||||
w32_mutex_lock(lock->mutex);
|
||||
w32_mutex_lock(lock->mutex, false);
|
||||
#else
|
||||
EnterCriticalSection(&lock->crit);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
rb_native_mutex_trylock(rb_nativethread_lock_t *lock)
|
||||
{
|
||||
#if USE_WIN32_MUTEX
|
||||
return w32_mutex_lock(lock->mutex, true);
|
||||
#else
|
||||
return TryEnterCriticalSection(&lock->crit) == 0 ? EBUSY : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
rb_native_mutex_unlock(rb_nativethread_lock_t *lock)
|
||||
{
|
||||
|
@ -340,27 +350,6 @@ rb_native_mutex_unlock(rb_nativethread_lock_t *lock)
|
|||
#endif
|
||||
}
|
||||
|
||||
RBIMPL_ATTR_MAYBE_UNUSED()
|
||||
static int
|
||||
native_mutex_trylock(rb_nativethread_lock_t *lock)
|
||||
{
|
||||
#if USE_WIN32_MUTEX
|
||||
int result;
|
||||
thread_debug("native_mutex_trylock: %p\n", lock->mutex);
|
||||
result = w32_wait_events(&lock->mutex, 1, 1, 0);
|
||||
thread_debug("native_mutex_trylock result: %d\n", result);
|
||||
switch (result) {
|
||||
case WAIT_OBJECT_0:
|
||||
return 0;
|
||||
case WAIT_TIMEOUT:
|
||||
return EBUSY;
|
||||
}
|
||||
return EINVAL;
|
||||
#else
|
||||
return TryEnterCriticalSection(&lock->crit) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
rb_native_mutex_initialize(rb_nativethread_lock_t *lock)
|
||||
{
|
||||
|
|
|
@ -54,17 +54,6 @@ native_tls_set(native_tls_key_t key, void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void rb_native_mutex_lock(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_unlock(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_initialize(rb_nativethread_lock_t *lock);
|
||||
void rb_native_mutex_destroy(rb_nativethread_lock_t *lock);
|
||||
void rb_native_cond_signal(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_broadcast(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_wait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex);
|
||||
void rb_native_cond_timedwait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex, unsigned long msec);
|
||||
void rb_native_cond_initialize(rb_nativethread_cond_t *cond);
|
||||
void rb_native_cond_destroy(rb_nativethread_cond_t *cond);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "transient_heap.h"
|
||||
#include "variable.h"
|
||||
#include "vm_core.h"
|
||||
#include "ractor_pub.h"
|
||||
#include "ractor_core.h"
|
||||
#include "vm_sync.h"
|
||||
|
||||
typedef void rb_gvar_compact_t(void *var);
|
||||
|
|
2
vm.c
2
vm.c
|
@ -35,7 +35,7 @@
|
|||
#include "vm_debug.h"
|
||||
#include "vm_exec.h"
|
||||
#include "vm_insnhelper.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
#include "vm_sync.h"
|
||||
|
||||
#include "builtin.h"
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "internal/vm.h"
|
||||
#include "iseq.h"
|
||||
#include "vm_core.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
|
||||
#define MAX_POSBUF 128
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "vm_core.h"
|
||||
#include "vm_sync.h"
|
||||
#include "ractor.h"
|
||||
#include "ractor_core.h"
|
||||
#include "vm_debug.h"
|
||||
#include "gc.h"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче