Skip to content

Commit

Permalink
Merge #199
Browse files Browse the repository at this point in the history
199: remove custom log code in favor of macro crate r=yoshuawuyts a=yoshuawuyts

This removes our custom log macro code in favor of using [`kv-log-macro`](https://github.com/yoshuawuyts/kv-log-macro). This is a temporary crate that exists only until rust-lang/log#353 lands which enables progress on rust-lang/log#328. Thanks!

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
  • Loading branch information
bors[bot] and yoshuawuyts authored Sep 16, 2019
2 parents be123b2 + 1341fa7 commit 36c437b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 63 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mio-uds = "0.6.7"
num_cpus = "1.10.1"
pin-utils = "0.1.0-alpha.4"
slab = "0.4.2"
kv-log-macro = "1.0.4"

[dev-dependencies]
femme = "1.2.0"
Expand Down
27 changes: 12 additions & 15 deletions src/task/block_on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ use std::sync::Arc;
use std::task::{RawWaker, RawWakerVTable};
use std::thread::{self, Thread};

use super::log_utils;
use super::pool;
use super::task;
use crate::future::Future;
use crate::task::{Context, Poll, Waker};
use crate::utils::abort_on_panic;

use kv_log_macro::trace;

/// Spawns a task and blocks the current thread on its result.
///
/// Calling this function is similar to [spawning] a thread and immediately [joining] it, except an
Expand Down Expand Up @@ -58,13 +59,11 @@ where
// Log this `block_on` operation.
let child_id = tag.task_id().as_u64();
let parent_id = pool::get_task(|t| t.id().as_u64()).unwrap_or(0);
log_utils::print(
format_args!("block_on"),
log_utils::LogData {
parent_id,
child_id,
},
);

trace!("block_on", {
parent_id: parent_id,
child_id: child_id,
});

// Wrap the future into one that drops task-local variables on exit.
let future = async move {
Expand All @@ -73,13 +72,11 @@ where
// Abort on panic because thread-local variables behave the same way.
abort_on_panic(|| pool::get_task(|task| task.metadata().local_map.clear()));

log_utils::print(
format_args!("block_on completed"),
log_utils::LogData {
parent_id,
child_id,
},
);
trace!("block_on completed", {
parent_id: parent_id,
child_id: child_id,
});

res
};

Expand Down
32 changes: 0 additions & 32 deletions src/task/log_utils.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub use task::{JoinHandle, Task, TaskId};

mod block_on;
mod local;
mod log_utils;
mod pool;
mod sleep;
mod task;
Expand Down
26 changes: 11 additions & 15 deletions src/task/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::ptr;
use std::thread;

use crossbeam_channel::{unbounded, Sender};
use kv_log_macro::trace;
use lazy_static::lazy_static;

use super::log_utils;
use super::task;
use super::{JoinHandle, Task};
use crate::future::Future;
Expand Down Expand Up @@ -130,13 +130,11 @@ where
// Log this `spawn` operation.
let child_id = tag.task_id().as_u64();
let parent_id = get_task(|t| t.id().as_u64()).unwrap_or(0);
log_utils::print(
format_args!("spawn"),
log_utils::LogData {
parent_id,
child_id,
},
);

trace!("spawn", {
parent_id: parent_id,
child_id: child_id,
});

// Wrap the future into one that drops task-local variables on exit.
let future = async move {
Expand All @@ -145,13 +143,11 @@ where
// Abort on panic because thread-local variables behave the same way.
abort_on_panic(|| get_task(|task| task.metadata().local_map.clear()));

log_utils::print(
format_args!("spawn completed"),
log_utils::LogData {
parent_id,
child_id,
},
);
trace!("spawn completed", {
parent_id: parent_id,
child_id: child_id,
});

res
};

Expand Down

0 comments on commit 36c437b

Please sign in to comment.