当前位置: 首页>>代码示例>>C++>>正文


C++ GetThreadPtr函数代码示例

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


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

示例1: rb_thread_priority_set

static VALUE
rb_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,代码来源:thread.c

示例2: thread_initialize

static VALUE
thread_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,代码来源:thread.c

示例3: rb_thread_kill

static VALUE
rb_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,代码来源:thread.c

示例4: stack_dump_th

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

示例5: thval2thread_t

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

示例6: rb_thread_abort_exc_set

static VALUE
rb_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,代码来源:thread.c

示例7: rb_thread_run

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

示例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,代码来源:binding_of_caller.c

示例9: rb_mutex_lock

static VALUE
rb_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,代码来源:thread.c

示例10: rb_vmdebug_thread_dump_regs

void
rb_vmdebug_thread_dump_regs(VALUE thval)
{
    rb_thread_t *th;
    GetThreadPtr(thval, th);
    rb_vmdebug_debug_print_register(th);
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:7,代码来源:vm_dump.c

示例11: rb_vmdebug_stack_dump_th

void
rb_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,代码来源:vm_dump.c

示例12: thread_initialize

static VALUE
thread_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,代码来源:thread.c

示例13: clear_trace_func_i

static int
clear_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,代码来源:vm_trace.c

示例14: rb_thread_status

static VALUE
rb_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,代码来源:thread.c

示例15: thread_add_trace_func_m

static VALUE
thread_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,代码来源:vm_trace.c


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