core: Remove pipes::spawn_service, spawn_service_recv
These are only used in test cases; pipes isn't the right place for them; they are unnecessary. Conflicts: src/libcore/rt/uv/mod.rs
This commit is contained in:
parent
b329f2fa82
commit
ab08b4fbfd
5 changed files with 102 additions and 55 deletions
|
|
@ -83,7 +83,6 @@ bounded and unbounded protocols allows for less code duplication.
|
|||
*/
|
||||
|
||||
use cast::{forget, reinterpret_cast, transmute};
|
||||
use cell::Cell;
|
||||
use either::{Either, Left, Right};
|
||||
use kinds::Owned;
|
||||
use libc;
|
||||
|
|
@ -902,51 +901,6 @@ pub fn entangle<T>() -> (SendPacket<T>, RecvPacket<T>) {
|
|||
(SendPacket(p), RecvPacket(p))
|
||||
}
|
||||
|
||||
/** Spawn a task to provide a service.
|
||||
|
||||
It takes an initialization function that produces a send and receive
|
||||
endpoint. The send endpoint is returned to the caller and the receive
|
||||
endpoint is passed to the new task.
|
||||
|
||||
*/
|
||||
pub fn spawn_service<T:Owned,Tb:Owned>(
|
||||
init: extern fn() -> (SendPacketBuffered<T, Tb>,
|
||||
RecvPacketBuffered<T, Tb>),
|
||||
service: ~fn(v: RecvPacketBuffered<T, Tb>))
|
||||
-> SendPacketBuffered<T, Tb> {
|
||||
let (client, server) = init();
|
||||
|
||||
// This is some nasty gymnastics required to safely move the pipe
|
||||
// into a new task.
|
||||
let server = Cell(server);
|
||||
do task::spawn {
|
||||
service(server.take());
|
||||
}
|
||||
|
||||
client
|
||||
}
|
||||
|
||||
/** Like `spawn_service_recv`, but for protocols that start in the
|
||||
receive state.
|
||||
|
||||
*/
|
||||
pub fn spawn_service_recv<T:Owned,Tb:Owned>(
|
||||
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
|
||||
SendPacketBuffered<T, Tb>),
|
||||
service: ~fn(v: SendPacketBuffered<T, Tb>))
|
||||
-> RecvPacketBuffered<T, Tb> {
|
||||
let (client, server) = init();
|
||||
|
||||
// This is some nasty gymnastics required to safely move the pipe
|
||||
// into a new task.
|
||||
let server = Cell(server);
|
||||
do task::spawn {
|
||||
service(server.take())
|
||||
}
|
||||
|
||||
client
|
||||
}
|
||||
|
||||
pub mod rt {
|
||||
use option::{None, Option, Some};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue