ocl_stream/executor/
context.rs

1/*
2 * opencl stream executor
3 * Copyright (C) 2021 trivernis
4 * See LICENSE for more information
5 */
6
7use crate::executor::stream::OCLStreamSender;
8use ocl::ProQue;
9
10/// Context passed to the executing closure
11/// to provide additional information and
12/// access to the ProQue.
13#[derive(Clone)]
14pub struct ExecutorContext<T>
15where
16    T: Send + Sync,
17{
18    pro_que: ProQue,
19    sender: OCLStreamSender<T>,
20    task_id: usize,
21}
22
23impl<T> ExecutorContext<T>
24where
25    T: Send + Sync,
26{
27    /// Creates a new executor context.
28    pub fn new(pro_que: ProQue, task_id: usize, sender: OCLStreamSender<T>) -> Self {
29        Self {
30            pro_que,
31            task_id,
32            sender,
33        }
34    }
35
36    /// Returns the ProQue
37    pub fn pro_que(&self) -> &ProQue {
38        &self.pro_que
39    }
40
41    /// Returns the Sender
42    pub fn sender(&self) -> &OCLStreamSender<T> {
43        &self.sender
44    }
45
46    /// Returns the unique task id of the scheduled
47    /// task
48    pub fn task_id(&self) -> usize {
49        self.task_id
50    }
51}