Skip to content

Commit

Permalink
[common, easy] Update crossbeam
Browse files Browse the repository at this point in the history
* This modifies the following behavior:
  - updates `crossbeam` in `proptest_helpers` to 0.7.2 (which was [just released](crossbeam-rs/crossbeam#401 (comment)))
  - removes usage of `crossbeam` in `common::logger` as:
    + `ArcCell` was [removed](crossbeam-rs/crossbeam#301) in more recent versions of crossbeam,
    + it was [spin-locking](crossbeam-rs/crossbeam#160) anyway

* Why this is better
  - closes #279
  - [`arc-swap`](https://docs.rs/arc-swap/) is (mostly) lock-free

* Why this is worse
  - [`arc-swap`](https://github.com/vorner/arc-swap) is young

* Tests

`cargo audit` + CI
  • Loading branch information
huitseeker committed Jul 25, 2019
1 parent a6a6a5a commit dec16d5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/logger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ publish = false
edition = "2018"

[dependencies]
arc-swap = "0.4.0-pre.1"
backtrace = { version = "0.3.33", features = ["serialize-serde"] }
chrono = "0.4.7"
crossbeam = "^0.4.1"
futures = "0.1.28"
hyper = "0.12.33"
itertools = "0.8.0"
Expand Down
10 changes: 5 additions & 5 deletions common/logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::{
http_local_slog_drain::HttpLocalSlogDrain, http_log_client::HttpLogClient,
kv_categorizer::ErrorCategorizer,
};
use crossbeam::atomic::ArcCell;
use arc_swap::ArcSwap;
use failure::prelude::*;
use glog_format::GlogFormat;
use lazy_static::lazy_static;
Expand Down Expand Up @@ -128,8 +128,8 @@ lazy_static! {
}

lazy_static! {
static ref GLOBAL_LOG_COLLECTOR: ArcCell<Logger> =
ArcCell::new(Arc::new(Logger::root(Discard, o!())));
static ref GLOBAL_LOG_COLLECTOR: ArcSwap<Logger> =
ArcSwap::from(Arc::new(Logger::root(Discard, o!())));
}

#[derive(Clone, Debug)]
Expand All @@ -144,7 +144,7 @@ pub enum LoggerType {
pub fn set_global_log_collector(collector: LoggerType, is_async: bool, chan_size: Option<usize>) {
// Log collector should be available at this time.
let log_collector = get_log_collector(collector, is_async, chan_size).unwrap();
GLOBAL_LOG_COLLECTOR.set(Arc::new(log_collector));
GLOBAL_LOG_COLLECTOR.store(Arc::new(log_collector));
}

/// Create and setup default global logger following the env-logger conventions,
Expand Down Expand Up @@ -198,7 +198,7 @@ pub fn with_logger<F, R>(f: F) -> R
where
F: FnOnce(&Logger) -> R,
{
f(&(*GLOBAL_LOG_COLLECTOR.get()))
f(&(*GLOBAL_LOG_COLLECTOR.load()))
}

/// Log a critical level message using current log collector
Expand Down
2 changes: 1 addition & 1 deletion common/proptest_helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ publish = false
edition = "2018"

[dependencies]
crossbeam = "0.7.1"
crossbeam = "0.7.2"
proptest = "0.9.4"
proptest-derive = "0.1.2"
2 changes: 1 addition & 1 deletion language/vm/vm_runtime/vm_cache_map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ chashmap = "2.2.2"
typed-arena = "1.4.1"

[dev-dependencies]
crossbeam = "0.7"
crossbeam = "0.7.2"
proptest = "0.9"
rand = "0.6.5"

0 comments on commit dec16d5

Please sign in to comment.