write-by-ref
k-nasa 5 years ago
parent 87b272f83d
commit f08fcd0bbb

@ -10,7 +10,7 @@ use crate::future::Future;
use crate::task::{Context, Poll, Waker}; use crate::task::{Context, Poll, Waker};
/// Set if the mutex is locked. /// Set if the mutex is locked.
const LOCK: usize = 1 << 0; const LOCK: usize = 1;
/// Set if there are tasks blocked on the mutex. /// Set if there are tasks blocked on the mutex.
const BLOCKED: usize = 1 << 1; const BLOCKED: usize = 1 << 1;

@ -10,7 +10,7 @@ use crate::future::Future;
use crate::task::{Context, Poll, Waker}; use crate::task::{Context, Poll, Waker};
/// Set if a write lock is held. /// Set if a write lock is held.
const WRITE_LOCK: usize = 1 << 0; const WRITE_LOCK: usize = 1;
/// Set if there are read operations blocked on the lock. /// Set if there are read operations blocked on the lock.
const BLOCKED_READS: usize = 1 << 1; const BLOCKED_READS: usize = 1 << 1;

@ -69,12 +69,11 @@ where
let future = task_local::add_finalizer(future); let future = task_local::add_finalizer(future);
let future = async move { let future = async move {
let res = future.await; future.await;
trace!("block_on completed", { trace!("block_on completed", {
parent_id: parent_id, parent_id: parent_id,
child_id: child_id, child_id: child_id,
}); });
res
}; };
// Pin the future onto the stack. // Pin the future onto the stack.

@ -135,7 +135,7 @@ fn random(n: u32) -> u32 {
use std::num::Wrapping; use std::num::Wrapping;
thread_local! { thread_local! {
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1406868647)); static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1_406_868_647));
} }
RNG.with(|rng| { RNG.with(|rng| {
@ -152,6 +152,6 @@ fn random(n: u32) -> u32 {
// //
// Author: Daniel Lemire // Author: Daniel Lemire
// Source: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/ // Source: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
((x.0 as u64).wrapping_mul(n as u64) >> 32) as u32 ((u64::from(x.0)).wrapping_mul(u64::from(n)) >> 32) as u32
}) })
} }

@ -4,7 +4,7 @@ use crate::future::Future;
use crate::io; use crate::io;
/// Task builder that configures the settings of a new task. /// Task builder that configures the settings of a new task.
#[derive(Debug)] #[derive(Debug, Default)]
pub struct Builder { pub struct Builder {
pub(crate) name: Option<String>, pub(crate) name: Option<String>,
} }

Loading…
Cancel
Save