您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetThreadPtr函数代码示例

51自学网 2021-06-01 21:16:24
  C++
这篇教程C++ GetThreadPtr函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetThreadPtr函数的典型用法代码示例。如果您正苦于以下问题:C++ GetThreadPtr函数的具体用法?C++ GetThreadPtr怎么用?C++ GetThreadPtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GetThreadPtr函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rb_thread_priority_set

static VALUErb_thread_priority_set(VALUE thread, SEL sel, VALUE prio){    // FIXME this doesn't really minic what 1.9 does, but do we care?    int policy;    struct sched_param param;    rb_secure(4);    pthread_assert(pthread_getschedparam(GetThreadPtr(thread)->thread,		&policy, &param));    const int max = sched_get_priority_max(policy);    const int min = sched_get_priority_min(policy);    int priority = FIX2INT(prio);    if (min > priority) {	priority = min;    }    else if (max > priority) {	priority = max;    }    param.sched_priority = priority;    pthread_assert(pthread_setschedparam(GetThreadPtr(thread)->thread,		policy, &param));    return Qnil;}
开发者ID:1nueve,项目名称:MacRuby,代码行数:27,


示例2: thread_initialize

static VALUEthread_initialize(VALUE thread, SEL sel, int argc, const VALUE *argv){    if (!rb_block_given_p()) {	rb_raise(rb_eThreadError, "must be called with a block");    }    rb_vm_block_t *b = rb_vm_current_block();    assert(b != NULL);    rb_vm_thread_t *t = GetThreadPtr(thread);    rb_vm_thread_pre_init(t, b, argc, argv, rb_vm_create_vm());    // The thread's group is always the parent's one.    rb_thgroup_add(GetThreadPtr(rb_vm_current_thread())->group, thread);    // Retain the Thread object to avoid a potential GC, the corresponding    // release is done in rb_vm_thread_run().    rb_objc_retain((void *)thread);    if (pthread_create(&t->thread, NULL, (void *(*)(void *))rb_vm_thread_run,		(void *)thread) != 0) {	rb_sys_fail("pthread_create() failed");    }    return thread;}
开发者ID:alloy,项目名称:mr-experimental,代码行数:26,


示例3: rb_thread_kill

static VALUErb_thread_kill(VALUE thread, SEL sel){    rb_vm_thread_t *t = GetThreadPtr(thread);    rb_vm_thread_t *t_main = GetThreadPtr(rb_vm_main_thread());     if (t->thread == t_main->thread) { 	rb_exit(EXIT_SUCCESS);     }     if (t->status != THREAD_KILLED) {	rb_vm_thread_cancel(t);    }    return thread;}
开发者ID:1nueve,项目名称:MacRuby,代码行数:13,


示例4: stack_dump_th

voidstack_dump_th(VALUE thval){    rb_thread_t *th;    GetThreadPtr(thval, th);    vm_stack_dump_raw(th, th->cfp);}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:7,


示例5: thval2thread_t

static rb_thread_t *thval2thread_t(VALUE thval){    rb_thread_t *th;    GetThreadPtr(thval, th);    return th;}
开发者ID:Chatto,项目名称:VGdesk,代码行数:7,


示例6: rb_thread_abort_exc_set

static VALUErb_thread_abort_exc_set(VALUE thread, SEL sel, VALUE val){    rb_secure(4);    GetThreadPtr(thread)->abort_on_exception = RTEST(val);    return val;}
开发者ID:1nueve,项目名称:MacRuby,代码行数:7,


示例7: rb_thread_run

static VALUErb_thread_run(VALUE thread, SEL sel){    rb_vm_thread_wakeup(GetThreadPtr(thread));    pthread_yield_np();    return thread;}
开发者ID:alloy,项目名称:mr-experimental,代码行数:7,


示例8: frame_count

static VALUE frame_count(VALUE self){  rb_thread_t *th;  GetThreadPtr(rb_thread_current(), th);  rb_control_frame_t *cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);  rb_control_frame_t *limit_cfp = (void *)(th->stack + th->stack_size);  int i = 1;  while (cfp < limit_cfp) {    cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);    if (cfp >= limit_cfp)      return INT2FIX(i);    // skip invalid frames    if (!valid_frame_p(cfp, limit_cfp))      cfp = find_valid_frame(cfp, limit_cfp);    if (!cfp)      break;    i++;  }  return INT2FIX(i);}
开发者ID:ottomatias,项目名称:discourse,代码行数:27,


示例9: rb_mutex_lock

static VALUErb_mutex_lock(VALUE self, SEL sel){    rb_vm_thread_t *current = GetThreadPtr(rb_vm_current_thread());    rb_vm_mutex_t *m = GetMutexPtr(self);    rb_vm_thread_status_t prev_status;    if (m->thread == current) {	rb_raise(rb_eThreadError, "deadlock; recursive locking");    }    prev_status = current->status;    if (current->status == THREAD_ALIVE) {	current->status = THREAD_SLEEP;    }    current->wait_for_mutex_lock = true;    pthread_assert(pthread_mutex_lock(&m->mutex));    current->wait_for_mutex_lock = false;    current->status = prev_status;    m->thread = current;    if (current->mutexes == Qnil) {	GC_WB(&current->mutexes, rb_ary_new());	OBJ_UNTRUST(current->mutexes);    }    rb_ary_push(current->mutexes, self);    return self;}
开发者ID:1nueve,项目名称:MacRuby,代码行数:27,


示例10: rb_vmdebug_thread_dump_regs

voidrb_vmdebug_thread_dump_regs(VALUE thval){    rb_thread_t *th;    GetThreadPtr(thval, th);    rb_vmdebug_debug_print_register(th);}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:7,


示例11: rb_vmdebug_stack_dump_th

voidrb_vmdebug_stack_dump_th(VALUE thval){    rb_thread_t *th;    GetThreadPtr(thval, th);    rb_vmdebug_stack_dump_raw(th, th->cfp);}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:7,


示例12: thread_initialize

static VALUEthread_initialize(VALUE thread, SEL sel, int argc, const VALUE *argv){    if (!rb_block_given_p()) {	rb_raise(rb_eThreadError, "must be called with a block");    }    rb_vm_block_t *b = rb_vm_current_block();    assert(b != NULL);    rb_vm_thread_t *t = GetThreadPtr(thread);    if (t->thread != 0) {	rb_raise(rb_eThreadError, "already initialized thread");    }    rb_vm_thread_pre_init(t, b, argc, argv, rb_vm_create_vm());    // The thread's group is always the parent's one.    // The parent group might be nil (ex. if created from GCD).    VALUE group = GetThreadPtr(rb_vm_current_thread())->group;    if (group != Qnil) {	thgroup_add_m(group, thread, false);    }    // Retain the Thread object to avoid a potential GC, the corresponding    // release is done in rb_vm_thread_run().    GC_RETAIN(thread);    // Prepare attributes for the thread.    pthread_attr_t attr;    pthread_attr_init(&attr);    pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);    // Register the thread to the core. We are doing this before actually    // running it because the current thread might perform a method poking at    // the current registered threads (such as Kernel#sleep) right after that.    rb_vm_register_thread(thread);    // Launch it.    if (pthread_create(&t->thread, &attr, (void *(*)(void *))rb_vm_thread_run,		(void *)thread) != 0) {	rb_sys_fail("pthread_create() failed");    }    pthread_attr_destroy(&attr);    return thread;}
开发者ID:1nueve,项目名称:MacRuby,代码行数:47,


示例13: clear_trace_func_i

static intclear_trace_func_i(st_data_t key, st_data_t val, st_data_t flag){    rb_thread_t *th;    GetThreadPtr((VALUE)key, th);    rb_threadptr_remove_event_hook(th, 0, Qundef);    return ST_CONTINUE;}
开发者ID:Chatto,项目名称:VGdesk,代码行数:8,


示例14: rb_thread_status

static VALUErb_thread_status(VALUE thread, SEL sel){    rb_vm_thread_t *t = GetThreadPtr(thread);    if (t->status == THREAD_DEAD) {	return t->exception == Qnil ? Qfalse : Qnil;    }    return rb_str_new2(rb_thread_status_cstr(thread));}
开发者ID:alloy,项目名称:mr-experimental,代码行数:9,


示例15: thread_add_trace_func_m

static VALUEthread_add_trace_func_m(VALUE obj, VALUE trace){    rb_thread_t *th;    GetThreadPtr(obj, th);    thread_add_trace_func(th, trace);    return trace;}
开发者ID:ksperling,项目名称:ruby,代码行数:9,


示例16: rb_thread_kill

static VALUErb_thread_kill(VALUE thread, SEL sel){    rb_vm_thread_t *t = GetThreadPtr(thread);    if (t->status != THREAD_KILLED) {	rb_vm_thread_cancel(t);    }    return thread;}
开发者ID:alloy,项目名称:mr-experimental,代码行数:9,


示例17: rb_mutex_trylock

static VALUErb_mutex_trylock(VALUE self, SEL sel){    if (pthread_mutex_trylock(&GetMutexPtr(self)->mutex) == 0) {	GetMutexPtr(self)->thread = GetThreadPtr(rb_vm_current_thread());	return Qtrue;    }    return Qfalse;}
开发者ID:alloy,项目名称:mr-experimental,代码行数:9,


示例18: rb_thread_priority

static VALUErb_thread_priority(VALUE thread, SEL sel){    // FIXME this doesn't really minic what 1.9 does, but do we care?    struct sched_param param;    pthread_assert(pthread_getschedparam(GetThreadPtr(thread)->thread,		NULL, &param));    return INT2FIX(param.sched_priority);}
开发者ID:1nueve,项目名称:MacRuby,代码行数:9,


示例19: thread_backtrace_to_ary

static VALUEthread_backtrace_to_ary(int argc, const VALUE *argv, VALUE thval, int to_str){    rb_thread_t *th;    GetThreadPtr(thval, th);    if (th->to_kill || th->status == THREAD_KILLED)	return Qnil;    return vm_backtrace_to_ary(th, argc, argv, 0, 0, to_str);}
开发者ID:sho-h,项目名称:ruby,代码行数:11,


示例20: set_cref_stack

static void set_cref_stack(rb_iseq_t * iseqdat, VALUE klass, VALUE noex){  VALUE thread = rb_thread_current();  rb_thread_t * th;  rb_control_frame_t * cfp;  GetThreadPtr(thread, th);  cfp = getcfp(th, th->cfp);  iseqdat->cref_stack = NEW_BLOCK(klass);  iseqdat->cref_stack->nd_visi = noex;  iseqdat->cref_stack->nd_next = cfp->iseq->cref_stack; /* TODO: use lfp? */}
开发者ID:shmulim,项目名称:ruby-internal,代码行数:12,


示例21: rb_tracepoint_new

VALUErb_tracepoint_new(VALUE target_thval, rb_event_flag_t events, void (*func)(VALUE, void *), void *data){    rb_thread_t *target_th = 0;    if (RTEST(target_thval)) {	GetThreadPtr(target_thval, target_th);	/* TODO: Test it!	 * Warning: This function is not tested.	 */    }    return tracepoint_new(rb_cTracePoint, target_th, events, func, data, Qundef);}
开发者ID:Chatto,项目名称:VGdesk,代码行数:12,


示例22: thread_finalize_imp

static voidthread_finalize_imp(void *rcv, SEL sel){    rb_vm_thread_t *t = GetThreadPtr(rcv);    if (t->exception != Qnil && !t->joined_on_exception) {	fprintf(stderr, "*** Thread %p exited prematurely because of an uncaught exception:/n%s/n",		t->thread,		rb_str_cstr(rb_format_exception_message(t->exception)));    }    if (thread_finalize_imp_super != NULL) {        ((void(*)(void *, SEL))thread_finalize_imp_super)(rcv, sel);    }}
开发者ID:1nueve,项目名称:MacRuby,代码行数:13,


示例23: rb_vmdebug_thread_dump_state

VALUErb_vmdebug_thread_dump_state(VALUE self){    rb_thread_t *th;    rb_control_frame_t *cfp;    GetThreadPtr(self, th);    cfp = th->cfp;    fprintf(stderr, "Thread state dump:/n");    fprintf(stderr, "pc : %p, sp : %p/n", (void *)cfp->pc, (void *)cfp->sp);    fprintf(stderr, "cfp: %p, lfp: %p, dfp: %p/n", (void *)cfp, (void *)cfp->lfp, (void *)cfp->dfp);    return Qnil;}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:14,


示例24: ruby_thread_init

static VALUEruby_thread_init(VALUE self){    rb_thread_t *th;    rb_vm_t *vm = GET_THREAD()->vm;    GetThreadPtr(self, th);    th_init(th, self);    th->vm = vm;    th->top_wrapper = 0;    th->top_self = rb_vm_top_self();    return self;}
开发者ID:qnighy,项目名称:ruby-1.9.2p0,代码行数:14,


示例25: thread_set_trace_func_m

static VALUEthread_set_trace_func_m(VALUE obj, VALUE trace){    rb_thread_t *th;    GetThreadPtr(obj, th);    rb_threadptr_remove_event_hook(th, call_trace_func, Qundef);    if (NIL_P(trace)) {        return Qnil;    }    thread_add_trace_func(th, trace);    return trace;}
开发者ID:ksperling,项目名称:ruby,代码行数:15,


示例26: thread_raise_m

static VALUEthread_raise_m(VALUE self, SEL sel, int argc, VALUE *argv){    VALUE exc = rb_make_exception(argc, argv);    rb_vm_thread_t *t = GetThreadPtr(self);    if (t->thread == pthread_self()) {	rb_exc_raise(exc);    }    else if (t->status != THREAD_DEAD) {	rb_vm_thread_raise(t, exc);    }    return Qnil;}
开发者ID:alloy,项目名称:mr-experimental,代码行数:16,


示例27: rb_thread_remove_from_group

voidrb_thread_remove_from_group(VALUE thread){    rb_vm_thread_t *t = GetThreadPtr(thread);    if (t->group != Qnil) {	rb_thread_group_t *tg = GetThreadGroupPtr(t->group);	thgroup_lock(tg);	if (rb_ary_delete(tg->threads, thread) != thread) {	    printf("trying to remove a thread (%p) from a group that doesn't "/		    "contain it/n", (void *)thread);	    abort();	}	thgroup_unlock(tg);	t->group = Qnil;    }}
开发者ID:1nueve,项目名称:MacRuby,代码行数:16,


示例28: cont_mark

static voidcont_mark(void *ptr){    RUBY_MARK_ENTER("cont");    if (ptr) {	rb_context_t *cont = ptr;	rb_gc_mark(cont->value);	rb_thread_mark(&cont->saved_thread);	rb_gc_mark(cont->saved_thread.self);	if (cont->vm_stack) {#ifdef CAPTURE_JUST_VALID_VM_STACK	    rb_gc_mark_locations(cont->vm_stack,				 cont->vm_stack + cont->vm_stack_slen + cont->vm_stack_clen);#else	    rb_gc_mark_locations(cont->vm_stack,				 cont->vm_stack, cont->saved_thread.stack_size);#endif	}	if (cont->machine.stack) {	    if (cont->type == CONTINUATION_CONTEXT) {		/* cont */		rb_gc_mark_locations(cont->machine.stack,				     cont->machine.stack + cont->machine.stack_size);            }            else {		/* fiber */		rb_thread_t *th;                rb_fiber_t *fib = (rb_fiber_t*)cont;		GetThreadPtr(cont->saved_thread.self, th);		if ((th->fiber != fib) && fib->status == RUNNING) {		    rb_gc_mark_locations(cont->machine.stack,					 cont->machine.stack + cont->machine.stack_size);		}	    }	}#ifdef __ia64	if (cont->machine.register_stack) {	    rb_gc_mark_locations(cont->machine.register_stack,				 cont->machine.register_stack + cont->machine.register_stack_size);	}#endif    }    RUBY_MARK_LEAVE("cont");}
开发者ID:rhenium,项目名称:ruby,代码行数:47,


示例29: rb_mutex_trylock

static VALUErb_mutex_trylock(VALUE self, SEL sel){    rb_vm_mutex_t *m = GetMutexPtr(self);    if (pthread_mutex_trylock(&m->mutex) == 0) {	rb_vm_thread_t *current = GetThreadPtr(rb_vm_current_thread());	m->thread = current;	if (current->mutexes == Qnil) {	    GC_WB(&current->mutexes, rb_ary_new());	    OBJ_UNTRUST(current->mutexes);	}	rb_ary_push(current->mutexes, self);	return Qtrue;    }    return Qfalse;}
开发者ID:1nueve,项目名称:MacRuby,代码行数:18,


示例30: rb_thread_status_cstr

static const char *rb_thread_status_cstr(VALUE thread){    rb_vm_thread_t *t = GetThreadPtr(thread);    switch (t->status) {	case THREAD_ALIVE:	    return "run";	case THREAD_SLEEP:	    return "sleep";	case THREAD_KILLED:	    return "aborting";	case THREAD_DEAD:	    return "dead";    }    return "unknown";}
开发者ID:alloy,项目名称:mr-experimental,代码行数:19,



注:本文中的GetThreadPtr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GetThumbRect函数代码示例
C++ GetThreadPriority函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。