pub struct StreamGuard { /* private fields */ }Expand description
RAII guard that sets the thread-local current stream on construction and restores the previous stream (or clears it) on drop.
§Example
ⓘ
use ferrotorch_gpu::stream::{StreamGuard, StreamPool};
let stream = StreamPool::get_stream(&ctx, 0)?;
{
let _guard = StreamGuard::new(0, stream);
// All operations on device 0 in this scope use `stream`.
// ...
}
// Previous stream (or default) is restored here.Implementations§
Source§impl StreamGuard
impl StreamGuard
Sourcepub fn new(device: usize, stream: Arc<CudaStream>) -> Self
pub fn new(device: usize, stream: Arc<CudaStream>) -> Self
Set stream as the current stream for device on this thread.
The previous current stream (if any) is saved and will be restored when this guard is dropped.
Trait Implementations§
Source§impl Debug for StreamGuard
Available on crate feature cuda only.
impl Debug for StreamGuard
Available on crate feature
cuda only.Auto Trait Implementations§
impl Freeze for StreamGuard
impl RefUnwindSafe for StreamGuard
impl Send for StreamGuard
impl Sync for StreamGuard
impl Unpin for StreamGuard
impl UnsafeUnpin for StreamGuard
impl UnwindSafe for StreamGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more