Skip to content

Commit 743ca28

Browse files
committed
Cache task handles.
1 parent 616b7af commit 743ca28

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/rt/rust_task.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ rust_task::rust_task(rust_dom *dom, rust_task *spawner, const char *name) :
6969
supervisor(spawner),
7070
idx(0),
7171
rendezvous_ptr(0),
72-
alarm(this)
72+
alarm(this),
73+
handle(NULL)
7374
{
7475
dom->logptr("new task", (uintptr_t)this);
7576

@@ -633,7 +634,10 @@ rust_task::log(uint32_t type_bits, char const *fmt, ...) {
633634

634635
rust_handle<rust_task> *
635636
rust_task::get_handle() {
636-
return dom->kernel->get_task_handle(this);
637+
if (handle == NULL) {
638+
handle = dom->kernel->get_task_handle(this);
639+
}
640+
return handle;
637641
}
638642

639643
//

src/rt/rust_task.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ rust_task : public maybe_proxy<rust_task>,
4646

4747
rust_alarm alarm;
4848

49+
rust_handle<rust_task> *handle;
50+
4951
// Only a pointer to 'name' is kept, so it must live as long as this task.
5052
rust_task(rust_dom *dom,
5153
rust_task *spawner,

0 commit comments

Comments
 (0)