mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-02 06:26:41 +00:00
refactor
This commit is contained in:
parent
87b272f83d
commit
f08fcd0bbb
5 changed files with 6 additions and 7 deletions
|
@ -10,7 +10,7 @@ use crate::future::Future;
|
|||
use crate::task::{Context, Poll, Waker};
|
||||
|
||||
/// Set if the mutex is locked.
|
||||
const LOCK: usize = 1 << 0;
|
||||
const LOCK: usize = 1;
|
||||
|
||||
/// Set if there are tasks blocked on the mutex.
|
||||
const BLOCKED: usize = 1 << 1;
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::future::Future;
|
|||
use crate::task::{Context, Poll, Waker};
|
||||
|
||||
/// 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.
|
||||
const BLOCKED_READS: usize = 1 << 1;
|
||||
|
|
|
@ -69,12 +69,11 @@ where
|
|||
let future = task_local::add_finalizer(future);
|
||||
|
||||
let future = async move {
|
||||
let res = future.await;
|
||||
future.await;
|
||||
trace!("block_on completed", {
|
||||
parent_id: parent_id,
|
||||
child_id: child_id,
|
||||
});
|
||||
res
|
||||
};
|
||||
|
||||
// Pin the future onto the stack.
|
||||
|
|
|
@ -135,7 +135,7 @@ fn random(n: u32) -> u32 {
|
|||
use std::num::Wrapping;
|
||||
|
||||
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| {
|
||||
|
@ -152,6 +152,6 @@ fn random(n: u32) -> u32 {
|
|||
//
|
||||
// Author: Daniel Lemire
|
||||
// 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;
|
||||
|
||||
/// Task builder that configures the settings of a new task.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Builder {
|
||||
pub(crate) name: Option<String>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue