summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-10-05 14:05:56 +0000
committerGitHub <noreply@github.com>2022-10-05 14:05:56 +0000
commit1b9479197d43785c550c1d722c476468672090b5 (patch)
tree6947bd5fa997cf3c00a1641567235b3b7880c5b9
parent94606833aa1ea5404cc8780ce233e07ecaa57b72 (diff)
parent530182d6683531f7c259448e6c54c866f35837c7 (diff)
downloadembassy-1b9479197d43785c550c1d722c476468672090b5.zip
Merge #1000
1000: Forgot to add space function to immediate publisher r=lulf a=diondokter Title says it all really. This function was added to the normal publisher, so now also to the immediate publisher Co-authored-by: Dion Dokter <dion@tweedegolf.com>
-rw-r--r--embassy-sync/src/pubsub/publisher.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/embassy-sync/src/pubsub/publisher.rs b/embassy-sync/src/pubsub/publisher.rs
index faa67d94..e1edc9eb 100644
--- a/embassy-sync/src/pubsub/publisher.rs
+++ b/embassy-sync/src/pubsub/publisher.rs
@@ -123,6 +123,14 @@ impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> ImmediatePub<'a, PSB, T> {
pub fn try_publish(&self, message: T) -> Result<(), T> {
self.channel.publish_with_context(message, None)
}
+
+ /// The amount of messages that can still be published without having to wait or without having to lag the subscribers
+ ///
+ /// *Note: In the time between checking this and a publish action, other publishers may have had time to publish something.
+ /// So checking doesn't give any guarantees.*
+ pub fn space(&self) -> usize {
+ self.channel.space()
+ }
}
/// An immediate publisher that holds a dynamic reference to the channel