sync: Convert statics to constants
This commit is contained in:
parent
4d87af9dce
commit
1a433770e3
@ -43,9 +43,9 @@ use atomic;
|
||||
use comm::Receiver;
|
||||
|
||||
// Various states you can find a port in.
|
||||
static EMPTY: uint = 0;
|
||||
static DATA: uint = 1;
|
||||
static DISCONNECTED: uint = 2;
|
||||
const EMPTY: uint = 0;
|
||||
const DATA: uint = 1;
|
||||
const DISCONNECTED: uint = 2;
|
||||
|
||||
pub struct Packet<T> {
|
||||
// Internal state of the chan/port pair (stores the blocked task as well)
|
||||
|
@ -31,12 +31,12 @@ use rustrt::thread::Thread;
|
||||
use atomic;
|
||||
use mpsc_queue as mpsc;
|
||||
|
||||
static DISCONNECTED: int = int::MIN;
|
||||
static FUDGE: int = 1024;
|
||||
const DISCONNECTED: int = int::MIN;
|
||||
const FUDGE: int = 1024;
|
||||
#[cfg(test)]
|
||||
static MAX_STEALS: int = 5;
|
||||
const MAX_STEALS: int = 5;
|
||||
#[cfg(not(test))]
|
||||
static MAX_STEALS: int = 1 << 20;
|
||||
const MAX_STEALS: int = 1 << 20;
|
||||
|
||||
pub struct Packet<T> {
|
||||
queue: mpsc::Queue<T>,
|
||||
|
@ -30,11 +30,11 @@ use atomic;
|
||||
use comm::Receiver;
|
||||
use spsc_queue as spsc;
|
||||
|
||||
static DISCONNECTED: int = int::MIN;
|
||||
const DISCONNECTED: int = int::MIN;
|
||||
#[cfg(test)]
|
||||
static MAX_STEALS: int = 5;
|
||||
const MAX_STEALS: int = 5;
|
||||
#[cfg(not(test))]
|
||||
static MAX_STEALS: int = 1 << 20;
|
||||
const MAX_STEALS: int = 1 << 20;
|
||||
|
||||
pub struct Packet<T> {
|
||||
queue: spsc::Queue<Message<T>>, // internal queue for all message
|
||||
|
@ -70,9 +70,9 @@ use rustrt::thread::Thread;
|
||||
|
||||
use mpsc_intrusive as q;
|
||||
|
||||
pub static LOCKED: uint = 1 << 0;
|
||||
pub static GREEN_BLOCKED: uint = 1 << 1;
|
||||
pub static NATIVE_BLOCKED: uint = 1 << 2;
|
||||
pub const LOCKED: uint = 1 << 0;
|
||||
pub const GREEN_BLOCKED: uint = 1 << 1;
|
||||
pub const NATIVE_BLOCKED: uint = 1 << 2;
|
||||
|
||||
/// A mutual exclusion primitive useful for protecting shared data
|
||||
///
|
||||
@ -163,7 +163,7 @@ pub struct Guard<'a> {
|
||||
|
||||
/// Static initialization of a mutex. This constant can be used to initialize
|
||||
/// other mutex constants.
|
||||
pub static MUTEX_INIT: StaticMutex = StaticMutex {
|
||||
pub const MUTEX_INIT: StaticMutex = StaticMutex {
|
||||
lock: mutex::NATIVE_MUTEX_INIT,
|
||||
state: atomic::INIT_ATOMIC_UINT,
|
||||
flavor: UnsafeCell { value: Unlocked },
|
||||
|
@ -45,7 +45,7 @@ pub struct Once {
|
||||
}
|
||||
|
||||
/// Initialization value for static `Once` values.
|
||||
pub static ONCE_INIT: Once = Once {
|
||||
pub const ONCE_INIT: Once = Once {
|
||||
mutex: MUTEX_INIT,
|
||||
cnt: atomic::INIT_ATOMIC_INT,
|
||||
lock_cnt: atomic::INIT_ATOMIC_INT,
|
||||
|
Loading…
x
Reference in New Issue
Block a user