The paper from which this example was taken made the mistake of assuming that all five philosophers are men. This it is a hypothetical example—there are no actual philosophers eating :spaghetti:—so there is no good reason to make this assumption. Since women make up about half of the human population, all things being equal, women should represent about half of the philosophers. However, because this mistake has stood since 1985, I have changed *all* of the pronouns to be female, to make up for lost time. If someone would like to revert this patch or switch to neutral pronouns after 30 years, feel free to set your alarm clock for 2045.
r? @steveklabnik, since this is a documentation change and was created after reading http://words.steveklabnik.com/ouroboros, where I noticed this mistake.
///
/// Leading and trailing whitespace represent an error.
///
- /// # Arguments
- ///
- /// * src - A string slice
- /// * radix - The base to use. Must lie in the range [2 .. 36]
- ///
- /// # Return value
+ /// # Examples
///
- /// `Err(ParseIntError)` if the string did not represent a valid number.
- /// Otherwise, `Ok(n)` where `n` is the integer represented by `src`.
+ /// ```
+ /// assert_eq!(u32::from_str_radix("A", 16), Some(10));
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub fn from_str_radix(src: &str, radix: u32) -> Result<$T, ParseIntError> {
unsafe { self.handle.kill() }
}
+ /// Returns the OS-assigned process identifier associated with this child.
+ #[unstable(feature = "process_id", reason = "api recently added")]
+ pub fn id(&self) -> u32 {
+ self.handle.id()
+ }
+
/// Waits for the child to exit completely, returning the status that it
/// exited with. This function will continue to have the same return value
/// after it has been called at least once.
fail(&mut output)
}
+ pub fn id(&self) -> u32 {
+ self.pid as u32
+ }
+
pub fn wait(&self) -> io::Result<ExitStatus> {
let mut status = 0 as c_int;
try!(cvt_r(|| unsafe { c::waitpid(self.pid, &mut status, 0) }));
dwMilliseconds: libc::DWORD) -> libc::DWORD;
pub fn SwitchToThread() -> libc::BOOL;
pub fn Sleep(dwMilliseconds: libc::DWORD);
+ pub fn GetProcessId(handle: libc::HANDLE) -> libc::DWORD;
}
#[link(name = "userenv")]
Ok(())
}
+ pub fn id(&self) -> u32 {
+ unsafe {
+ c::GetProcessId(self.handle.raw()) as u32
+ }
+ }
+
pub fn wait(&self) -> io::Result<ExitStatus> {
use libc::{STILL_ACTIVE, INFINITE, WAIT_OBJECT_0};
use libc::{GetExitCodeProcess, WaitForSingleObject};