add some inlines to shared mutable state

This commit is contained in:
Ben Blum
2012-08-14 20:36:36 -04:00
parent 6d68658b9a
commit a63f85ce8c

View File

@@ -105,6 +105,7 @@ unsafe fn shared_mutable_state<T: send>(+data: T) -> SharedMutableState<T> {
} }
} }
#[inline(always)]
unsafe fn get_shared_mutable_state<T: send>(rc: &SharedMutableState<T>) unsafe fn get_shared_mutable_state<T: send>(rc: &SharedMutableState<T>)
-> &mut T { -> &mut T {
unsafe { unsafe {
@@ -116,6 +117,7 @@ unsafe fn get_shared_mutable_state<T: send>(rc: &SharedMutableState<T>)
return r; return r;
} }
} }
#[inline(always)]
unsafe fn get_shared_immutable_state<T: send>(rc: &SharedMutableState<T>) unsafe fn get_shared_immutable_state<T: send>(rc: &SharedMutableState<T>)
-> &T { -> &T {
unsafe { unsafe {
@@ -169,6 +171,7 @@ class LittleLock {
} }
impl LittleLock { impl LittleLock {
#[inline(always)]
unsafe fn lock<T>(f: fn() -> T) -> T { unsafe fn lock<T>(f: fn() -> T) -> T {
class Unlock { class Unlock {
let l: rust_little_lock; let l: rust_little_lock;
@@ -209,6 +212,7 @@ impl<T: send> Exclusive<T> {
// Currently, scheduling operations (i.e., yielding, receiving on a pipe, // Currently, scheduling operations (i.e., yielding, receiving on a pipe,
// accessing the provided condition variable) are prohibited while inside // accessing the provided condition variable) are prohibited while inside
// the exclusive. Supporting that is a work in progress. // the exclusive. Supporting that is a work in progress.
#[inline(always)]
unsafe fn with<U>(f: fn(x: &mut T) -> U) -> U { unsafe fn with<U>(f: fn(x: &mut T) -> U) -> U {
let rec = unsafe { get_shared_mutable_state(&self.x) }; let rec = unsafe { get_shared_mutable_state(&self.x) };
do rec.lock.lock { do rec.lock.lock {