Move channel cloning logic into a method on rust_chan.
This will allow us to more easily clone channels from native code.
This commit is contained in:
parent
396c4defcc
commit
09921cf86f
@ -97,6 +97,25 @@ void rust_chan::send(void *sptr) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
rust_chan *rust_chan::clone(maybe_proxy<rust_task> *target) {
|
||||
size_t unit_sz = buffer.unit_sz;
|
||||
maybe_proxy<rust_port> *port = this->port;
|
||||
rust_task *target_task = NULL;
|
||||
if (target->is_proxy() == false) {
|
||||
port = this->port;
|
||||
target_task = target->referent();
|
||||
} else {
|
||||
rust_handle<rust_port> *handle =
|
||||
task->sched->kernel->get_port_handle(port->as_referent());
|
||||
maybe_proxy<rust_port> *proxy = new rust_proxy<rust_port> (handle);
|
||||
LOG(task, mem, "new proxy: " PTR, proxy);
|
||||
port = proxy;
|
||||
target_task = target->as_proxy()->handle()->referent();
|
||||
}
|
||||
return new (target_task) rust_chan(target_task, port, unit_sz);
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
|
@ -19,6 +19,8 @@ public:
|
||||
bool is_associated();
|
||||
|
||||
void send(void *sptr);
|
||||
|
||||
rust_chan *clone(maybe_proxy<rust_task> *target);
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -166,21 +166,7 @@ upcall_clone_chan(rust_task *task, maybe_proxy<rust_task> *target,
|
||||
rust_chan *chan) {
|
||||
LOG_UPCALL_ENTRY(task);
|
||||
scoped_lock with(task->kernel->scheduler_lock);
|
||||
size_t unit_sz = chan->buffer.unit_sz;
|
||||
maybe_proxy<rust_port> *port = chan->port;
|
||||
rust_task *target_task = NULL;
|
||||
if (target->is_proxy() == false) {
|
||||
port = chan->port;
|
||||
target_task = target->referent();
|
||||
} else {
|
||||
rust_handle<rust_port> *handle =
|
||||
task->sched->kernel->get_port_handle(port->as_referent());
|
||||
maybe_proxy<rust_port> *proxy = new rust_proxy<rust_port> (handle);
|
||||
LOG(task, mem, "new proxy: " PTR, proxy);
|
||||
port = proxy;
|
||||
target_task = target->as_proxy()->handle()->referent();
|
||||
}
|
||||
return new (target_task) rust_chan(target_task, port, unit_sz);
|
||||
return chan->clone(target);
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
|
Loading…
x
Reference in New Issue
Block a user