Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address comments
  • Loading branch information
Zoxc committed Mar 1, 2019
commit 35a1b91c4b4153027a722a267ba0bcdfec6d2bfe
13 changes: 8 additions & 5 deletions src/librustc_data_structures/jobserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::{Condvar, Arc, Mutex};
use std::mem;

#[derive(Default)]
pub struct LockedProxyData {
struct LockedProxyData {
/// The number of free thread tokens, this may include the implicit token given to the process
free: usize,

Expand Down Expand Up @@ -72,12 +72,15 @@ impl LockedProxyData {
}

#[derive(Default)]
pub struct ProxyData {
struct ProxyData {
lock: Mutex<LockedProxyData>,
cond_var: Condvar,
}

pub struct Proxy {
/// A helper type which makes managing jobserver tokens easier.
/// It also allows you to treat the implicit token given to the process
/// in the same manner as requested tokens.
struct Proxy {
thread: Mutex<HelperThread>,
data: Arc<ProxyData>,
}
Expand Down Expand Up @@ -131,11 +134,11 @@ pub fn release_thread() {
}

impl Proxy {
pub fn release_token(&self) {
fn release_token(&self) {
self.data.lock.lock().unwrap().release_token(&self.data.cond_var);
}

pub fn acquire_token(&self) {
fn acquire_token(&self) {
let mut data = self.data.lock.lock().unwrap();
data.waiters += 1;
if data.take_token(&self.thread) {
Expand Down