Called the new_task upcall. There are refcount issues though.
This commit is contained in:
parent
41b3979990
commit
d01948cd07
3 changed files with 27 additions and 4 deletions
|
@ -122,7 +122,7 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
|
||||||
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||||
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
|
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
|
||||||
T_ptr(T_tydesc(tn))),
|
T_ptr(T_tydesc(tn))),
|
||||||
new_task=d("new_task", [T_ptr(T_i8())], T_taskptr(tn)),
|
new_task=d("new_task", [T_ptr(T_str())], T_taskptr(tn)),
|
||||||
start_task=d("start_task", [T_taskptr(tn), T_int(), T_int(),
|
start_task=d("start_task", [T_taskptr(tn), T_int(), T_int(),
|
||||||
T_int(), T_size_t()],
|
T_int(), T_size_t()],
|
||||||
T_taskptr(tn)),
|
T_taskptr(tn)),
|
||||||
|
|
|
@ -5903,7 +5903,8 @@ fn trans_spawn(&@block_ctxt cx,
|
||||||
};
|
};
|
||||||
|
|
||||||
// dump a bunch of information
|
// dump a bunch of information
|
||||||
log_err "Spawn";
|
log_err "Translating Spawn " +
|
||||||
|
"(The compiled program is not actually running yet, don't worry!";
|
||||||
log_err #fmt("task name: %s", tname);
|
log_err #fmt("task name: %s", tname);
|
||||||
|
|
||||||
// Generate code
|
// Generate code
|
||||||
|
@ -5920,6 +5921,8 @@ fn trans_spawn(&@block_ctxt cx,
|
||||||
//
|
//
|
||||||
// 4. Pass a pointer to the spawnee function and the argument tuple to
|
// 4. Pass a pointer to the spawnee function and the argument tuple to
|
||||||
// upcall_start_task.
|
// upcall_start_task.
|
||||||
|
//
|
||||||
|
// 5. Oh yeah, we have to create the task before we start it...
|
||||||
|
|
||||||
// Translate the arguments, remembering their types and where the values
|
// Translate the arguments, remembering their types and where the values
|
||||||
// ended up.
|
// ended up.
|
||||||
|
@ -5961,6 +5964,23 @@ fn trans_spawn(&@block_ctxt cx,
|
||||||
|
|
||||||
// Now we're ready to do the upcall.
|
// Now we're ready to do the upcall.
|
||||||
|
|
||||||
|
// But first, we'll create a task.
|
||||||
|
let ValueRef lltname = C_str(bcx.fcx.lcx.ccx, tname);
|
||||||
|
log_err #fmt("ty(new_task) = %s",
|
||||||
|
val_str(bcx.fcx.lcx.ccx.tn,
|
||||||
|
bcx.fcx.lcx.ccx.upcalls.new_task));
|
||||||
|
log_err #fmt("ty(lltaskptr) = %s",
|
||||||
|
val_str(bcx.fcx.lcx.ccx.tn,
|
||||||
|
bcx.fcx.lltaskptr));
|
||||||
|
log_err #fmt("ty(lltname) = %s",
|
||||||
|
val_str(bcx.fcx.lcx.ccx.tn,
|
||||||
|
lltname));
|
||||||
|
|
||||||
|
log_err "Building upcall_new_task";
|
||||||
|
auto new_task = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.new_task,
|
||||||
|
[bcx.fcx.lltaskptr, lltname]);
|
||||||
|
log_err "Done";
|
||||||
|
|
||||||
alt(dom) {
|
alt(dom) {
|
||||||
case(ast::dom_implicit) {
|
case(ast::dom_implicit) {
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -5975,6 +5995,8 @@ fn trans_spawn(&@block_ctxt cx,
|
||||||
fail;
|
fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret res(bcx, new_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
|
fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
|
||||||
|
|
|
@ -538,10 +538,11 @@ upcall_get_type_desc(rust_task *task,
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" CDECL rust_task *
|
extern "C" CDECL rust_task *
|
||||||
upcall_new_task(rust_task *spawner, const char *name) {
|
upcall_new_task(rust_task *spawner, rust_vec *name) {
|
||||||
|
// name is a rust string structure.
|
||||||
LOG_UPCALL_ENTRY(spawner);
|
LOG_UPCALL_ENTRY(spawner);
|
||||||
rust_dom *dom = spawner->dom;
|
rust_dom *dom = spawner->dom;
|
||||||
rust_task *task = dom->create_task(spawner, name);
|
rust_task *task = dom->create_task(spawner, (const char *)name->data);
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue