pub struct Stream { /* private fields */ }
Expand description
This class encapsulates a queue of asynchronous calls.
Note: Currently, you may face problems if an operation is enqueued twice with different data. Some functions use the constant GPU memory, and next call may update the memory before the previous one has been finished. But calling different operations asynchronously is safe because each operation has its own constant buffer. Memory copy/upload/download/set operations to the buffers you hold are also safe.
Note: The Stream class is not thread-safe. Please use different Stream objects for different CPU threads.
void thread1()
{
cv::cuda::Stream stream1;
cv::cuda::func1(..., stream1);
}
void thread2()
{
cv::cuda::Stream stream2;
cv::cuda::func2(..., stream2);
}
Note: By default all CUDA routines are launched in Stream::Null() object, if the stream is not specified by user. In multi-threading environment the stream objects must be passed explicitly (see previous note).
Implementations§
Source§impl Stream
impl Stream
Sourcepub fn new(allocator: &Ptr<GpuMat_Allocator>) -> Result<Stream>
pub fn new(allocator: &Ptr<GpuMat_Allocator>) -> Result<Stream>
creates a new asynchronous stream with custom allocator
Sourcepub fn new_1(cuda_flags: size_t) -> Result<Stream>
pub fn new_1(cuda_flags: size_t) -> Result<Stream>
creates a new Stream using the cudaFlags argument to determine the behaviors of the stream
Note: The cudaFlags parameter is passed to the underlying api cudaStreamCreateWithFlags() and supports the same parameter values.
// creates an OpenCV cuda::Stream that manages an asynchronous, non-blocking,
// non-default CUDA stream
cv::cuda::Stream cvStream(cudaStreamNonBlocking);
Trait Implementations§
Source§impl Boxed for Stream
impl Boxed for Stream
Source§unsafe fn from_raw(ptr: <Stream as OpenCVFromExtern>::ExternReceive) -> Self
unsafe fn from_raw(ptr: <Stream as OpenCVFromExtern>::ExternReceive) -> Self
Source§fn into_raw(self) -> <Stream as OpenCVTypeExternContainer>::ExternSendMut
fn into_raw(self) -> <Stream as OpenCVTypeExternContainer>::ExternSendMut
Source§fn as_raw(&self) -> <Stream as OpenCVTypeExternContainer>::ExternSend
fn as_raw(&self) -> <Stream as OpenCVTypeExternContainer>::ExternSend
Source§fn as_raw_mut(&mut self) -> <Stream as OpenCVTypeExternContainer>::ExternSendMut
fn as_raw_mut(&mut self) -> <Stream as OpenCVTypeExternContainer>::ExternSendMut
Source§impl StreamTrait for Stream
impl StreamTrait for Stream
fn as_raw_mut_Stream(&mut self) -> *mut c_void
Source§fn wait_for_completion(&mut self) -> Result<()>
fn wait_for_completion(&mut self) -> Result<()>
Source§fn wait_event(&mut self, event: &impl EventTraitConst) -> Result<()>
fn wait_event(&mut self, event: &impl EventTraitConst) -> Result<()>
Source§fn enqueue_host_callback(
&mut self,
callback: Stream_StreamCallback,
) -> Result<()>
fn enqueue_host_callback( &mut self, callback: Stream_StreamCallback, ) -> Result<()>
Source§impl StreamTraitConst for Stream
impl StreamTraitConst for Stream
impl Send for Stream
Auto Trait Implementations§
impl Freeze for Stream
impl RefUnwindSafe for Stream
impl !Sync for Stream
impl Unpin for Stream
impl UnwindSafe for Stream
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
Source§impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
Source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res,
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res
Mat
or another similar object. By passing
a mutable reference to the Mat
to this function your closure will get called with the read reference and a write references
to the same Mat
. This is unsafe in a general case as it leads to having non-exclusive mutable access to the internal data,
but it can be useful for some performance sensitive operations. One example of an OpenCV function that allows such in-place
modification is imgproc::threshold
. Read more