From dcaf10f8de7be79d7ef8aa5e048bf6535108dc16 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 4 Jan 2014 00:06:13 -0800 Subject: Add a stack_bounds function to the Runtime trait This allows inspection of the current task's bounds regardless of what the underlying task is. Closes #11293 --- src/libstd/rt/mod.rs | 1 + src/libstd/rt/task.rs | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'src/libstd/rt') diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 9bd804f7bab..050caef86eb 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -159,6 +159,7 @@ pub trait Runtime { // you're in. fn spawn_sibling(~self, cur_task: ~Task, opts: TaskOpts, f: proc()); fn local_io<'a>(&'a mut self) -> Option>; + fn stack_bounds(&self) -> Option<(uint, uint)>; // (lo, hi) // XXX: This is a serious code smell and this should not exist at all. fn wrap(~self) -> ~Any; diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 583a1e0657c..3fdbc8938ba 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -277,6 +277,13 @@ impl Task { pub fn local_io<'a>(&'a mut self) -> Option> { self.imp.get_mut_ref().local_io() } + + /// Returns the stack bounds for this task in (lo, hi) format. The stack + /// bounds may not be known for all tasks, so the return value may be + /// `None`. + pub fn stack_bounds(&self) -> Option<(uint, uint)> { + self.imp.get_ref().stack_bounds() + } } impl Drop for Task { -- cgit 1.4.1-3-g733a5