Skip to content

Commit

Permalink
Merge pull request #98 from matklad/debug
Browse files Browse the repository at this point in the history
show SharedState in Debug for Runtime
  • Loading branch information
nikomatsakis authored Dec 28, 2018
2 parents 36d99f0 + 52206d5 commit 7074e25
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ where
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt.debug_struct("Runtime")
.field("id", &self.id())
.field("revision", &self.current_revision())
.field("forked", &self.revision_guard.is_some())
.field("shared_state", &self.shared_state)
.finish()
}
}
Expand Down Expand Up @@ -398,6 +399,26 @@ impl<DB: Database> Default for SharedState<DB> {
}
}

impl<DB> std::fmt::Debug for SharedState<DB>
where
DB: Database,
{
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let query_lock = if self.query_lock.try_write().is_some() {
"<unlocked>"
} else if self.query_lock.try_read().is_some() {
"<rlocked>"
} else {
"<wlocked>"
};
fmt.debug_struct("SharedState")
.field("query_lock", &query_lock)
.field("revision", &self.revision)
.field("pending_revision_increments", &self.pending_revision_increments)
.finish()
}
}

/// State that will be specific to a single execution threads (when we
/// support multiple threads)
struct LocalState<DB: Database> {
Expand Down

0 comments on commit 7074e25

Please sign in to comment.