Skip to content

Commit

Permalink
Merge pull request #49 from mh84/master
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v2d0g authored Oct 16, 2019
2 parents 408cc63 + aa4441b commit 4a16b74
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ backtrace = "0.3.32"
ego-tree = "0.6.0"
lazy_static = "1.3.0"
objekt = "0.1.2"
parking_lot = "0.9"


#futures-preview = "=0.3.0-alpha.16"
uuid = { version = "0.7", features = ["serde", "v4"] }
Expand Down
26 changes: 12 additions & 14 deletions src/bastion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use futures::future::poll_fn;
use lazy_static::lazy_static;
use log::LevelFilter;

use parking_lot::Mutex;
use std::mem;
use std::panic::AssertUnwindSafe;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::sync::Mutex;
use tokio::prelude::future::FutureResult;
use tokio::prelude::*;
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -166,9 +166,9 @@ impl Bastion {
}

fn traverse(ns: Supervisor) -> Supervisor {
let runtime = PLATFORM.lock();
let runtime = PLATFORM.lock().unwrap();
let arcreg = runtime.registry.clone();
let registry = arcreg.lock();
let registry = arcreg.lock().unwrap();
Bastion::traverse_registry(registry.clone(), registry.root(), &ns);

ns
Expand All @@ -180,7 +180,7 @@ impl Bastion {

// Push supervisor for next trampoline
let fark = FAULTED.clone();
let mut faulted_ones = fark.lock();
let mut faulted_ones = fark.lock().unwrap();
faulted_ones.push(given.clone());

debug!("Fault induced supervisors: {:?}", faulted_ones);
Expand Down Expand Up @@ -274,7 +274,7 @@ impl Bastion {
if let Err(err) = result {
error!("Panic happened in restarted - {:?}", err);
let fark = FAULTED.clone();
let mut faulted_ones = fark.lock();
let mut faulted_ones = fark.lock().unwrap();
let faulted = faulted_ones.pop().unwrap();

// Make trampoline to re-enter
Expand All @@ -287,7 +287,7 @@ impl Bastion {
);

let ark = PLATFORM.clone();
let mut runtime = ark.lock();
let mut runtime = ark.lock().unwrap();
let shared_runtime: &mut Runtime = &mut runtime.runtime;
shared_runtime.spawn(k);
}
Expand Down Expand Up @@ -384,8 +384,8 @@ impl Bastion {
let root_spv;
{
let ark = PLATFORM.clone();
let runtime = ark.lock();
let mut registry = runtime.registry.lock();
let runtime = ark.lock().unwrap();
let mut registry = runtime.registry.lock().unwrap();
let mut rootn = registry.root_mut();
let root: &mut Supervisor = rootn.value();

Expand Down Expand Up @@ -415,8 +415,8 @@ impl Bastion {
.catch_unwind()
.then(|result| -> FutureResult<(), ()> {
let ark = PLATFORM.clone();
let runtime = ark.lock();
let mut registry = runtime.registry.lock();
let runtime = ark.lock().unwrap();
let mut registry = runtime.registry.lock().unwrap();
let mut rootn = registry.root_mut();
let mut root = rootn.value().clone();

Expand All @@ -433,7 +433,7 @@ impl Bastion {
});

let ark = PLATFORM.clone();
let mut runtime = ark.lock();
let mut runtime = ark.lock().unwrap();
let shared_runtime: &mut Runtime = &mut runtime.runtime;
shared_runtime.spawn(k);

Expand All @@ -446,12 +446,10 @@ const CLOSE_OVER: Result<Async<()>, Never> = Ok(Async::Ready(()));

impl RuntimeManager for Bastion {
fn unstable_shutdown() {
let ark = PLATFORM.clone();
unsafe {
if let Some(lock_ptr) = ark.clone().try_lock() {
if let Ok(lock_ptr) = PLATFORM.clone().try_lock() {
let l: RuntimeSystem = mem::transmute_copy(&*lock_ptr);
l.runtime.shutdown_now().wait().unwrap();
ark.force_unlock_fair();
mem::forget(lock_ptr);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl BastionContext {
});

let ark = crate::bastion::PLATFORM.clone();
let mut runtime = ark.lock();
let mut runtime = ark.lock().unwrap();
let shared_runtime = &mut runtime.runtime;
shared_runtime.spawn(k);
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_system.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::runtime_manager::FaultRecovery;
use crate::supervisor::Supervisor;
use ego_tree::Tree;
use parking_lot::Mutex;
use std::any::Any;
use std::sync::Arc;
use std::sync::Mutex;
use tokio::runtime::{Builder, Runtime};

pub struct RuntimeSystem {
Expand Down
2 changes: 1 addition & 1 deletion src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl Supervisor {
});

let ark = crate::bastion::PLATFORM.clone();
let mut runtime = ark.lock();
let mut runtime = ark.lock().unwrap();
let shared_runtime = &mut runtime.runtime;
shared_runtime.spawn(k);
}
Expand Down

0 comments on commit 4a16b74

Please sign in to comment.