Skip to content

Commit

Permalink
Made ROOT_SPV private and added a "root_supervisor" to System.
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v2d0g committed Nov 9, 2019
1 parent fc89463 commit ad5e847
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bastion/src/bastion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::broadcast::{Broadcast, Parent};
use crate::children::{Children, ChildrenRef};
use crate::message::{BastionMessage, Message};
use crate::supervisor::{Supervisor, SupervisorRef};
use crate::system::{ROOT_SPV, SYSTEM, SYSTEM_SENDER};
use crate::system::{System, SYSTEM, SYSTEM_SENDER};
use std::fmt::{self, Debug, Formatter};
use std::thread;

Expand Down Expand Up @@ -266,7 +266,7 @@ impl Bastion {
C: FnOnce(Children) -> Children,
{
// FIXME: unsafe?
if let Some(supervisor) = unsafe { &ROOT_SPV } {
if let Some(supervisor) = System::root_supervisor() {
supervisor.children(init)
} else {
// TODO: Err(Error)
Expand Down
6 changes: 5 additions & 1 deletion bastion/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use qutex::Qutex;
use std::cell::RefCell;
use std::task::Poll;

pub(crate) static mut ROOT_SPV: Option<SupervisorRef> = None;
static mut ROOT_SPV: Option<SupervisorRef> = None;

lazy_static! {
pub(crate) static ref SYSTEM: Qutex<Option<RecoverableHandle<()>>> = Qutex::new(None);
Expand Down Expand Up @@ -75,6 +75,10 @@ impl System {
sender
}

pub(crate) fn root_supervisor() -> Option<&'static SupervisorRef> {
unsafe { ROOT_SPV.as_ref() }
}

// TODO: set a limit?
async fn recover(&mut self, mut supervisor: Supervisor) {
let parent = Parent::system();
Expand Down

0 comments on commit ad5e847

Please sign in to comment.