Skip to content

Commit b7f2d15

Browse files
committed
refactor: add some inlining
1 parent 22339b2 commit b7f2d15

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/queue.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ where
297297
/// let queue: Queue<VecBuffer<usize>> = Queue::with_capacity(42);
298298
/// assert!(queue.is_empty());
299299
/// ```
300+
#[inline]
300301
pub fn is_empty(&self) -> bool {
301302
self.len() == 0
302303
}
@@ -312,6 +313,7 @@ where
312313
/// queue.close();
313314
/// assert!(queue.is_closed());
314315
/// ```
316+
#[inline]
315317
pub fn is_closed(&self) -> bool {
316318
EnqueuingCapacity::from_atomic(self.enqueuing_capacity.load(Ordering::Relaxed)).is_closed()
317319
}
@@ -330,6 +332,7 @@ where
330332
/// queue.reopen();
331333
/// assert!(!queue.is_closed());
332334
/// ```
335+
#[inline]
333336
pub fn reopen(&self) {
334337
EnqueuingCapacity::reopen(&self.enqueuing_capacity, Ordering::AcqRel);
335338
}
@@ -487,6 +490,7 @@ where
487490
);
488491
}
489492

493+
#[inline]
490494
pub(crate) fn get_slice(&self, buffer_index: usize, range: Range<usize>) -> B::Slice<'_> {
491495
self.buffers[buffer_index]
492496
// SAFETY: Dequeued buffer pointed by buffer index can be accessed mutably
@@ -495,6 +499,7 @@ where
495499
.with_mut(|buf| unsafe { (*buf).slice(range.clone()) })
496500
}
497501

502+
#[inline]
498503
pub(crate) fn requeue(&self, buffer_index: usize, range: Range<usize>) {
499504
// Requeuing the buffer just means saving the dequeuing state (or release if there is
500505
// nothing to requeue).

src/synchronized.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl<B> SynchronizedQueue<B>
5151
where
5252
B: Buffer,
5353
{
54+
#[inline]
5455
fn enqueue_sync<T>(
5556
&self,
5657
mut value: T,
@@ -413,6 +414,7 @@ where
413414
}
414415
}
415416

417+
#[inline]
416418
fn try_enqueue<B, T>(
417419
queue: &SynchronizedQueue<B>,
418420
mut value: T,
@@ -438,6 +440,7 @@ where
438440
}
439441
}
440442

443+
#[inline]
441444
fn try_dequeue<'a, B>(
442445
queue: &'a SynchronizedQueue<B>,
443446
cx: Option<&Context>,
@@ -459,6 +462,7 @@ where
459462
}
460463
}
461464

465+
#[inline]
462466
fn dequeue_err(error: TryDequeueError) -> DequeueError {
463467
match error {
464468
TryDequeueError::Closed => DequeueError::Closed,
@@ -467,6 +471,7 @@ fn dequeue_err(error: TryDequeueError) -> DequeueError {
467471
}
468472
}
469473

474+
#[inline]
470475
fn wait_until(deadline: Option<Instant>) -> bool {
471476
match deadline.map(|d| d.checked_duration_since(Instant::now())) {
472477
#[cfg(not(all(loom, test)))]

0 commit comments

Comments
 (0)