Skip to content

Commit 47c1895

Browse files
committed
rt: Don't store the name of the task state in rust_task_list
1 parent 05466c6 commit 47c1895

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

src/rt/rust_task_list.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "rust_internal.h"
22

3-
rust_task_list::rust_task_list (rust_task_thread *thread, const char* name) :
4-
thread(thread), name(name) {
3+
rust_task_list::rust_task_list (rust_task_thread *thread) :
4+
thread(thread) {
55
}
66

77
void
88
rust_task_list::delete_all() {
9-
DLOG(thread, task, "deleting all %s tasks", name);
9+
DLOG(thread, task, "deleting all tasks");
1010
while (is_empty() == false) {
1111
rust_task *task = pop_value();
1212
DLOG(thread, task, "deleting task " PTR, task);

src/rt/rust_task_list.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ class rust_task_list : public indexed_list<rust_task>,
99
public kernel_owned<rust_task_list> {
1010
public:
1111
rust_task_thread *thread;
12-
const char* name;
13-
rust_task_list (rust_task_thread *thread, const char* name);
12+
rust_task_list (rust_task_thread *thread);
1413
void delete_all();
1514
};
1615

src/rt/rust_task_thread.cpp

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ rust_task_thread::rust_task_thread(rust_scheduler *sched,
2727
id(id),
2828
should_exit(false),
2929
cached_c_stack(NULL),
30-
newborn_tasks(this, "newborn"),
31-
running_tasks(this, "running"),
32-
blocked_tasks(this, "blocked"),
33-
dead_tasks(this, "dead"),
30+
newborn_tasks(this),
31+
running_tasks(this),
32+
blocked_tasks(this),
33+
dead_tasks(this),
3434
kernel(sched->kernel),
3535
sched(sched),
3636
srv(srv),
@@ -248,7 +248,7 @@ rust_task_thread::start_main_loop() {
248248
", state: %s",
249249
scheduled_task->name,
250250
(uintptr_t)scheduled_task,
251-
state_list(scheduled_task->get_state())->name);
251+
state_name(scheduled_task->get_state()));
252252

253253
place_task_in_tls(scheduled_task);
254254

@@ -262,7 +262,7 @@ rust_task_thread::start_main_loop() {
262262
" in state '%s', worker id=%d" PRIxPTR,
263263
scheduled_task->name,
264264
(uintptr_t)scheduled_task,
265-
state_list(scheduled_task->get_state())->name,
265+
state_name(scheduled_task->get_state()),
266266
id);
267267

268268
reap_dead_tasks();
@@ -316,20 +316,35 @@ rust_task_thread::state_list(rust_task_state state) {
316316
}
317317
}
318318

319+
const char *
320+
rust_task_thread::state_name(rust_task_state state) {
321+
switch (state) {
322+
case task_state_newborn:
323+
return "newborn";
324+
case task_state_running:
325+
return "running";
326+
case task_state_blocked:
327+
return "blocked";
328+
case task_state_dead:
329+
return "dead";
330+
default:
331+
assert(false);
332+
return "";
333+
}
334+
}
335+
319336
void
320337
rust_task_thread::transition(rust_task *task,
321338
rust_task_state src, rust_task_state dst,
322339
rust_cond *cond, const char* cond_name) {
323340
scoped_lock with(lock);
324-
rust_task_list *src_list = state_list(src);
325-
rust_task_list *dst_list = state_list(dst);
326341
DLOG(this, task,
327342
"task %s " PTR " state change '%s' -> '%s' while in '%s'",
328-
name, (uintptr_t)this, src_list->name, dst_list->name,
329-
state_list(task->get_state())->name);
343+
name, (uintptr_t)this, state_name(src), state_name(dst),
344+
state_name(task->get_state()));
330345
I(this, task->get_state() == src);
331-
src_list->remove(task);
332-
dst_list->append(task);
346+
state_list(src)->remove(task);
347+
state_list(dst)->append(task);
333348
task->set_state(dst, cond, cond_name);
334349

335350
lock.signal();

src/rt/rust_task_thread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct rust_task_thread : public kernel_owned<rust_task_thread>,
5454
void unprepare_c_stack();
5555

5656
rust_task_list *state_list(rust_task_state state);
57+
const char *state_name(rust_task_state state);
5758

5859
public:
5960
rust_kernel *kernel;

0 commit comments

Comments
 (0)