Skip to content

green: Fix missing Send bounds on procedures #13630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libgreen/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ mod test {
})
}

fn run(f: proc()) {
fn run(f: proc():Send) {
let mut pool = pool();
pool.spawn(TaskOpts::new(), f);
pool.shutdown();
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Context {
/// FIXME: this is basically an awful the interface. The main reason for
/// this is to reduce the number of allocations made when a green
/// task is spawned as much as possible
pub fn new(init: InitFn, arg: uint, start: proc(),
pub fn new(init: InitFn, arg: uint, start: proc():Send,
stack: &mut Stack) -> Context {

let sp: *uint = stack.end();
Expand Down
8 changes: 4 additions & 4 deletions src/libgreen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ macro_rules! green_start( ($f:ident) => (
/// error.
pub fn start(argc: int, argv: **u8,
event_loop_factory: fn() -> ~rtio::EventLoop:Send,
main: proc()) -> int {
main: proc():Send) -> int {
rt::init(argc, argv);
let mut main = Some(main);
let mut ret = None;
Expand All @@ -310,7 +310,7 @@ pub fn start(argc: int, argv: **u8,
/// This function will not return until all schedulers in the associated pool
/// have returned.
pub fn run(event_loop_factory: fn() -> ~rtio::EventLoop:Send,
main: proc()) -> int {
main: proc():Send) -> int {
// Create a scheduler pool and spawn the main task into this pool. We will
// get notified over a channel when the main task exits.
let mut cfg = PoolConfig::new();
Expand Down Expand Up @@ -445,7 +445,7 @@ impl SchedPool {
/// This is useful to create a task which can then be sent to a specific
/// scheduler created by `spawn_sched` (and possibly pin it to that
/// scheduler).
pub fn task(&mut self, opts: TaskOpts, f: proc()) -> ~GreenTask {
pub fn task(&mut self, opts: TaskOpts, f: proc():Send) -> ~GreenTask {
GreenTask::configure(&mut self.stack_pool, opts, f)
}

Expand All @@ -455,7 +455,7 @@ impl SchedPool {
/// New tasks are spawned in a round-robin fashion to the schedulers in this
/// pool, but tasks can certainly migrate among schedulers once they're in
/// the pool.
pub fn spawn(&mut self, opts: TaskOpts, f: proc()) {
pub fn spawn(&mut self, opts: TaskOpts, f: proc():Send) {
let task = self.task(opts, f);

// Figure out someone to send this task to
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ mod test {
})
}

fn run(f: proc()) {
fn run(f: proc():Send) {
let mut pool = pool();
pool.spawn(TaskOpts::new(), f);
pool.shutdown();
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Runtime for SimpleTask {
// feet and running.
fn yield_now(~self, _cur_task: ~Task) { fail!() }
fn maybe_yield(~self, _cur_task: ~Task) { fail!() }
fn spawn_sibling(~self, _cur_task: ~Task, _opts: TaskOpts, _f: proc()) {
fn spawn_sibling(~self, _cur_task: ~Task, _opts: TaskOpts, _f: proc():Send) {
fail!()
}
fn local_io<'a>(&'a mut self) -> Option<rtio::LocalIo<'a>> { None }
Expand Down
10 changes: 5 additions & 5 deletions src/libgreen/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ impl GreenTask {
/// and will not have any contained Task structure.
pub fn new(stack_pool: &mut StackPool,
stack_size: Option<uint>,
start: proc()) -> ~GreenTask {
start: proc():Send) -> ~GreenTask {
GreenTask::new_homed(stack_pool, stack_size, AnySched, start)
}

/// Creates a new task (like `new`), but specifies the home for new task.
pub fn new_homed(stack_pool: &mut StackPool,
stack_size: Option<uint>,
home: Home,
start: proc()) -> ~GreenTask {
start: proc():Send) -> ~GreenTask {
// Allocate ourselves a GreenTask structure
let mut ops = GreenTask::new_typed(None, TypeGreen(Some(home)));

Expand Down Expand Up @@ -175,7 +175,7 @@ impl GreenTask {
/// new stack for this task.
pub fn configure(pool: &mut StackPool,
opts: TaskOpts,
f: proc()) -> ~GreenTask {
f: proc():Send) -> ~GreenTask {
let TaskOpts {
notify_chan, name, stack_size,
stderr, stdout,
Expand Down Expand Up @@ -443,7 +443,7 @@ impl Runtime for GreenTask {
}
}

fn spawn_sibling(mut ~self, cur_task: ~Task, opts: TaskOpts, f: proc()) {
fn spawn_sibling(mut ~self, cur_task: ~Task, opts: TaskOpts, f: proc():Send) {
self.put_task(cur_task);

// Spawns a task into the current scheduler. We allocate the new task's
Expand Down Expand Up @@ -490,7 +490,7 @@ mod tests {
use super::super::{PoolConfig, SchedPool};
use super::GreenTask;

fn spawn_opts(opts: TaskOpts, f: proc()) {
fn spawn_opts(opts: TaskOpts, f: proc():Send) {
let mut pool = SchedPool::new(PoolConfig {
threads: 1,
event_loop_factory: ::rustuv::event_loop,
Expand Down