Skip to content

Commit 83f7c8a

Browse files
committed
---
yaml --- r: 11641 b: refs/heads/master c: 2465a63 h: refs/heads/master i: 11639: 464c8af v: v3
1 parent a0f8392 commit 83f7c8a

File tree

5 files changed

+43
-23
lines changed

5 files changed

+43
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 237652299ec5fa3529ac7bd1bfddc52b7526bb82
2+
refs/heads/master: 2465a63a69ea51d4fce10430b6a8fd0079cbbcd5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rt/rust_task.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -401,26 +401,16 @@ rust_task::free(void *p)
401401
void
402402
rust_task::transition(rust_task_list *src, rust_task_list *dst,
403403
rust_cond *cond, const char* cond_name) {
404-
bool unlock = false;
405-
if(!thread->lock.lock_held_by_current_thread()) {
406-
unlock = true;
407-
thread->lock.lock();
408-
}
409-
DLOG(thread, task,
410-
"task %s " PTR " state change '%s' -> '%s' while in '%s'",
411-
name, (uintptr_t)this, src->name, dst->name, state->name);
412-
I(thread, state == src);
413-
src->remove(this);
414-
dst->append(this);
415-
{
416-
scoped_lock with(state_lock);
417-
state = dst;
418-
this->cond = cond;
419-
this->cond_name = cond_name;
420-
}
421-
thread->lock.signal();
422-
if(unlock)
423-
thread->lock.unlock();
404+
thread->transition(this, src, dst, cond, cond_name);
405+
}
406+
407+
void
408+
rust_task::set_state(rust_task_list *state,
409+
rust_cond *cond, const char* cond_name) {
410+
scoped_lock with(state_lock);
411+
this->state = state;
412+
this->cond = cond;
413+
this->cond_name = cond_name;
424414
}
425415

426416
void

trunk/src/rt/rust_task.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ rust_task : public kernel_owned<rust_task>, rust_cond
137137

138138
void return_c_stack();
139139

140+
void transition(rust_task_list *src, rust_task_list *dst,
141+
rust_cond *cond, const char* cond_name);
142+
140143
friend void task_start_wrapper(spawn_args *a);
141144
friend void cleanup_task(cleanup_args *a);
142145
friend void reset_stack_limit_on_c_stack(reset_args *a);
@@ -163,8 +166,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
163166
void *realloc(void *data, size_t sz);
164167
void free(void *p);
165168

166-
void transition(rust_task_list *src, rust_task_list *dst,
167-
rust_cond *cond, const char* cond_name);
169+
void set_state(rust_task_list *state,
170+
rust_cond *cond, const char* cond_name);
168171

169172
void block(rust_cond *on, const char* name);
170173
void wakeup(rust_cond *from);

trunk/src/rt/rust_task_thread.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,29 @@ rust_task_thread::create_task(rust_task *spawner, const char *name,
319319
return task->id;
320320
}
321321

322+
void
323+
rust_task_thread::transition(rust_task *task,
324+
rust_task_list *src, rust_task_list *dst,
325+
rust_cond *cond, const char* cond_name) {
326+
bool unlock = false;
327+
if(!lock.lock_held_by_current_thread()) {
328+
unlock = true;
329+
lock.lock();
330+
}
331+
DLOG(this, task,
332+
"task %s " PTR " state change '%s' -> '%s' while in '%s'",
333+
name, (uintptr_t)this, src->name, dst->name,
334+
task->get_state()->name);
335+
I(this, task->get_state() == src);
336+
src->remove(task);
337+
dst->append(task);
338+
task->set_state(dst, cond, cond_name);
339+
340+
lock.signal();
341+
if(unlock)
342+
lock.unlock();
343+
}
344+
322345
void rust_task_thread::run() {
323346
this->start_main_loop();
324347
sched->release_task_thread();

trunk/src/rt/rust_task_thread.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ struct rust_task_thread : public kernel_owned<rust_task_thread>,
123123
rust_task_id create_task(rust_task *spawner, const char *name,
124124
size_t init_stack_sz);
125125

126+
void transition(rust_task *task,
127+
rust_task_list *src, rust_task_list *dst,
128+
rust_cond *cond, const char* cond_name);
129+
126130
virtual void run();
127131

128132
void init_tls();

0 commit comments

Comments
 (0)