mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_trace.c (rb_postponed_job_flush): simplify.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
19ae2748c7
commit
76f9281b92
2 changed files with 21 additions and 38 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Oct 11 16:53:28 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* vm_trace.c (rb_postponed_job_flush): simplify.
|
||||||
|
|
||||||
Fri Oct 11 03:36:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Oct 11 03:36:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* thread.c (rb_threadptr_execute_interrupts): flush postponed job only
|
* thread.c (rb_threadptr_execute_interrupts): flush postponed job only
|
||||||
|
|
55
vm_trace.c
55
vm_trace.c
|
@ -1444,46 +1444,25 @@ rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func,
|
||||||
void
|
void
|
||||||
rb_postponed_job_flush(rb_vm_t *vm)
|
rb_postponed_job_flush(rb_vm_t *vm)
|
||||||
{
|
{
|
||||||
rb_thread_t *cur_th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
volatile struct {
|
unsigned long saved_postponed_job_interrupt_mask = th->interrupt_mask & POSTPONED_JOB_INTERRUPT_MASK;
|
||||||
rb_thread_t *thread;
|
|
||||||
unsigned long interrupt_mask;
|
|
||||||
int index, old_index;
|
|
||||||
} save;
|
|
||||||
int index = vm->postponed_job_index, old_index = index;
|
|
||||||
|
|
||||||
save.thread = cur_th;
|
/* mask POSTPONED_JOB dispatch */
|
||||||
save.index = index;
|
th->interrupt_mask |= POSTPONED_JOB_INTERRUPT_MASK;
|
||||||
save.interrupt_mask = cur_th->interrupt_mask;
|
{
|
||||||
|
TH_PUSH_TAG(th);
|
||||||
cur_th->interrupt_mask |= POSTPONED_JOB_INTERRUPT_MASK;
|
EXEC_TAG();
|
||||||
TH_PUSH_TAG(cur_th);
|
{
|
||||||
EXEC_TAG();
|
int index;
|
||||||
/* ignore all jumps, just continue */
|
while ((index = vm->postponed_job_index) > 0) {
|
||||||
cur_th = save.thread;
|
if (ATOMIC_CAS(vm->postponed_job_index, index, index-1) == index) {
|
||||||
index = save.index;
|
rb_postponed_job_t *pjob = &vm->postponed_job_buffer[index-1];
|
||||||
old_index = save.old_index;
|
(*pjob->func)(pjob->data);
|
||||||
while (index > 0) {
|
}
|
||||||
rb_postponed_job_t *pjob = &vm->postponed_job_buffer[--index];
|
|
||||||
void *data = pjob->data;
|
|
||||||
rb_postponed_job_func_t func = pjob->func;
|
|
||||||
|
|
||||||
pjob->func = 0; /* not to execute again */
|
|
||||||
if (old_index > 0) {
|
|
||||||
if (ATOMIC_CAS(vm->postponed_job_index, old_index, index) == old_index) {
|
|
||||||
old_index = index;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
old_index = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
save.index = index;
|
TH_POP_TAG();
|
||||||
save.old_index = old_index;
|
|
||||||
if (func) {
|
|
||||||
/* do postponed job */
|
|
||||||
(*func)(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
TH_POP_TAG();
|
/* restore POSTPONED_JOB mask */
|
||||||
cur_th->interrupt_mask = save.interrupt_mask;
|
th->interrupt_mask &= ~saved_postponed_job_interrupt_mask;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue