diff options
Diffstat (limited to 'ecs/src/lock.rs')
-rw-r--r-- | ecs/src/lock.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ecs/src/lock.rs b/ecs/src/lock.rs index fbc6842..135f654 100644 --- a/ecs/src/lock.rs +++ b/ecs/src/lock.rs @@ -28,7 +28,7 @@ where pub fn read_nonblock(&self) -> Result<ReadGuard<Value>, Error> { let guard = self.inner.try_read().or_else(|err| match err { - TryLockError::WouldBlock => Err(Error::Unavailable), + TryLockError::WouldBlock => Err(Error::ReadUnavailable), TryLockError::Poisoned(poison_err) => Ok(poison_err.into_inner()), })?; @@ -45,7 +45,7 @@ where pub fn write_nonblock(&self) -> Result<WriteGuard<Value>, Error> { let guard = self.inner.try_write().or_else(|err| match err { - TryLockError::WouldBlock => Err(Error::Unavailable), + TryLockError::WouldBlock => Err(Error::WriteUnavailable), TryLockError::Poisoned(poison_err) => Ok(poison_err.into_inner()), })?; @@ -69,8 +69,11 @@ where #[derive(Debug, thiserror::Error)] pub enum Error { - #[error("Lock is unavailable")] - Unavailable, + #[error("Lock is unavailable for reading")] + ReadUnavailable, + + #[error("Lock is unavailable for writing")] + WriteUnavailable, } #[derive(Debug)] |