Skip to content

Commit a5f71b8

Browse files
committed
Make PROFQ_CHAN a global
1 parent 11524d5 commit a5f71b8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/librustc/util/common.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#![allow(non_camel_case_types)]
1212

13+
use rustc_data_structures::sync::Lock;
14+
1315
use std::cell::{RefCell, Cell};
1416
use std::collections::HashMap;
1517
use std::ffi::CString;
@@ -35,7 +37,7 @@ pub struct ErrorReported;
3537
thread_local!(static TIME_DEPTH: Cell<usize> = Cell::new(0));
3638

3739
/// Initialized for -Z profile-queries
38-
thread_local!(static PROFQ_CHAN: RefCell<Option<Sender<ProfileQueriesMsg>>> = RefCell::new(None));
40+
rustc_global!(static PROFQ_CHAN: Lock<Option<Sender<ProfileQueriesMsg>>> = Lock::new(None));
3941

4042
/// Parameters to the `Dump` variant of type `ProfileQueriesMsg`.
4143
#[derive(Clone,Debug)]
@@ -77,7 +79,7 @@ pub enum ProfileQueriesMsg {
7779

7880
/// If enabled, send a message to the profile-queries thread
7981
pub fn profq_msg(msg: ProfileQueriesMsg) {
80-
PROFQ_CHAN.with(|sender|{
82+
rustc_access_global!(PROFQ_CHAN, |sender| {
8183
if let Some(s) = sender.borrow().as_ref() {
8284
s.send(msg).unwrap()
8385
} else {
@@ -93,7 +95,7 @@ pub fn profq_msg(msg: ProfileQueriesMsg) {
9395

9496
/// Set channel for profile queries channel
9597
pub fn profq_set_chan(s: Sender<ProfileQueriesMsg>) -> bool {
96-
PROFQ_CHAN.with(|chan|{
98+
rustc_access_global!(PROFQ_CHAN, |chan| {
9799
if chan.borrow().is_none() {
98100
*chan.borrow_mut() = Some(s);
99101
true

0 commit comments

Comments
 (0)