From 4f068467c4954fb79e6ce297ae1ac0fdd2bdf16a Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:24 +0100 Subject: WIP refactor(skeleton): type state for context also some api improvements closes #2 related: #7 --- stockton-skeleton/src/queue_negotiator.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'stockton-skeleton/src/queue_negotiator.rs') diff --git a/stockton-skeleton/src/queue_negotiator.rs b/stockton-skeleton/src/queue_negotiator.rs index b78fe33..765516b 100644 --- a/stockton-skeleton/src/queue_negotiator.rs +++ b/stockton-skeleton/src/queue_negotiator.rs @@ -70,7 +70,7 @@ impl QueueFamilyNegotiator { mut count: usize, ) -> Result<()> { if let Entry::Occupied(e) = self.family_ids.entry(TypeId::of::()) { - count = count + e.get().0; + count += e.get().0; } let candidates: Vec<&QueueFamilyT> = adapter @@ -123,7 +123,7 @@ impl QueueFamilyNegotiator { } /// Finish selecting our queue families, and turn this into a `QueueNegotiator` - pub fn finish<'a>(self, queue_groups: Vec) -> QueueNegotiator { + pub fn finish(self, queue_groups: Vec) -> QueueNegotiator { QueueNegotiator { family_ids: self.family_ids, already_allocated: HashMap::new(), @@ -132,6 +132,12 @@ impl QueueFamilyNegotiator { } } +impl Default for QueueFamilyNegotiator { + fn default() -> Self { + Self::new() + } +} + /// Used internally in calls to [`hal::adapter::PhysicalDevice::open`] pub(crate) struct AdapterOpenSpec<'a>(Box<[(&'a QueueFamilyT, Vec)]>); @@ -164,7 +170,7 @@ impl QueueNegotiator { /// You should already have called [`self::QueueFamilyNegotiator::find`], otherwise this will return an error. /// /// The family of the queue returned is guaranteed to meet the spec of the `QueueFamilySelector` originally used by `find`. - pub fn get_queue(&mut self) -> Result>> { + pub fn get_queue(&mut self) -> Result { let tid = TypeId::of::(); let (_, family_id) = self .family_ids -- cgit v1.2.3