本文整理汇总了C++中thread::ThreadData类的典型用法代码示例。如果您正苦于以下问题:C++ ThreadData类的具体用法?C++ ThreadData怎么用?C++ ThreadData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ThreadData类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ManagedThread
//.........这里部分代码省略.........
#endif
#ifdef ENABLE_LLVM
if(!shared.config.jit_disabled) {
Array* ary = Array::create(this, 3);
ary->append(this, symbol("usage"));
if(shared.config.jit_inline_generic) {
ary->append(this, symbol("inline_generic"));
}
if(shared.config.jit_inline_blocks) {
ary->append(this, symbol("inline_blocks"));
}
G(rubinius)->set_const(this, "JIT", ary);
} else {
G(rubinius)->set_const(this, "JIT", Qfalse);
}
#else
G(rubinius)->set_const(this, "JIT", Qnil);
#endif
}
// HACK so not thread safe or anything!
static VM* __state = NULL;
VM* VM::current_state() {
return __state;
}
void VM::register_state(VM *vm) {
__state = vm;
}
thread::ThreadData<VM*> _current_vm;
VM* VM::current() {
return _current_vm.get();
}
void VM::set_current(VM* vm) {
_current_vm.set(vm);
}
void VM::boot_threads() {
thread.set(Thread::create(this, this, pthread_self()), &globals().roots);
thread->sleep(this, Qfalse);
VM::set_current(this);
}
Object* VM::new_object_typed(Class* cls, size_t bytes, object_type type) {
return om->new_object_typed(cls, bytes, type);
}
Object* VM::new_object_typed_mature(Class* cls, size_t bytes, object_type type) {
return om->new_object_typed_mature(cls, bytes, type);
}
Object* VM::new_object_from_type(Class* cls, TypeInfo* ti) {
return om->new_object_typed(cls, ti->instance_size, ti->type);
}
Class* VM::new_basic_class(Class* sup) {
Class *cls = om->new_object_enduring<Class>(G(klass));
cls->set_class_id(shared.inc_class_count());
cls->set_packed_size(0);
示例2: set_current
void VM::set_current(VM* vm) {
_current_vm.set(vm);
}
示例3: current
VM* VM::current() {
return _current_vm.get();
}
示例4: executor_implementation
Object* NativeMethod::executor_implementation(STATE,
CallFrame* call_frame, Dispatch& msg, Arguments& args) {
NativeMethod* nm = as<NativeMethod>(msg.method);
int arity = nm->arity()->to_int();
if(arity >= 0 && (size_t)arity != args.total()) {
Exception* exc = Exception::make_argument_error(
state, arity, args.total(), msg.name);
exc->locations(state, Location::from_call_stack(state, call_frame));
state->thread_state()->raise_exception(exc);
return NULL;
}
NativeMethodEnvironment* env = native_method_environment.get();
// Optionally get the handles back to the proper state.
if(state->shared.config.capi_global_flush) {
capi::Handles* handles = state->shared.cached_handles();
if(handles->size() > 0) {
for(capi::Handles::Iterator i(*handles); i.more(); i.advance()) {
i->update(env);
}
}
}
// Register the CallFrame, because we might GC below this.
state->set_call_frame(call_frame);
NativeMethodFrame nmf(env->current_native_frame());
CallFrame* saved_frame = env->current_call_frame();
env->set_current_call_frame(call_frame);
env->set_current_native_frame(&nmf);
// Be sure to do this after installing nmf as the current
// native frame.
nmf.setup(
env->get_handle(args.recv()),
env->get_handle(args.block()),
env->get_handle(msg.method),
env->get_handle(msg.module));
Object* ret;
ExceptionPoint ep(env);
PLACE_EXCEPTION_POINT(ep);
if(unlikely(ep.jumped_to())) {
ret = NULL;
} else {
#ifdef RBX_PROFILER
if(unlikely(state->tooling())) {
tooling::MethodEntry method(state, msg, args);
ret = ArgumentHandler::invoke(state, nm, env, args);
} else {
ret = ArgumentHandler::invoke(state, nm, env, args);
}
#else
ret = ArgumentHandler::invoke(state, nm, env, args);
#endif
}
env->set_current_call_frame(saved_frame);
env->set_current_native_frame(nmf.previous());
ep.pop(env);
// Handle any signals that occurred while the native method
// was running.
if(!state->check_async(call_frame)) return NULL;
return ret;
}
示例5: get
NativeMethodEnvironment* NativeMethodEnvironment::get() {
return native_method_environment.get();
}
示例6: cleanup_thread
void NativeMethod::cleanup_thread(STATE) {
delete native_method_environment.get();
native_method_environment.set(NULL);
}
示例7: init_thread
void NativeMethod::init_thread(STATE) {
NativeMethodEnvironment* env = new NativeMethodEnvironment(state);
native_method_environment.set(env);
}