mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-12 16:35:21 +00:00
Merge pull request #98 from matklad/debug
show SharedState in Debug for Runtime
This commit is contained in:
commit
7074e258ba
1 changed files with 22 additions and 1 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue