pub enum Submission<Ps> {
Added(TaskInf<Ps>),
Updated(TaskInf<Ps>),
}Expand description
Represents how a value was inserted into the system or queue.
Variants§
Added(TaskInf<Ps>)
Added: The task ID was not present; a new task was inserted.
Updated(TaskInf<Ps>)
Updated: The task ID already existed; the existing task was updated.
Implementations§
Source§impl<Ps> Submission<Ps>
impl<Ps> Submission<Ps>
Sourcepub const fn take(self) -> TaskInf<Ps>
pub const fn take(self) -> TaskInf<Ps>
Consumes self and returns the inner TaskInf<Ps>.
Examples found in repository?
examples/spsc.rs (line 40)
34fn produce_task(submitter:TaskSubmitter) {
35 prompt("hello");
36 submitter.submit((||println!("consmue task='hello': hello everyone!")).into_task());
37
38 prompt("exit");
39 let id_exit = submitter.submit((|a:i32|println!("consume task='exit': recv cond={a} and exit.")).into_exit_task())
40 .take();
41
42 prompt("add");
43 let id_add = submitter.submit(
44 (|a:i32,b:i32|{
45 println!("consume task='add': ({a},{b}) and then pass (r={}) to Task='exit'",a+b);
46 a+b
47 }).into_task().bind_to(id_exit.input_ca::<0>())
48 ).take();
49
50 prompt("params");
51 let _ = submitter.submit(
52 (||{println!("consume task='params': pass (1,2) to task='add'");1},10.into())
53 .into_task()
54 .map_tuple_with(move|_:i32| (1,2))
55 .bind_all_to((id_add.input_ca::<0>(),id_add.input_ca::<1>()))
56 );
57}More examples
examples/simple.rs (line 26)
4fn main() {
5 println!("----- test task orch -----");
6
7 // Step#1. create a Pool
8 let mut pool = Pool::new();
9
10 // Step#2. create a queue
11 let qid = pool.insert_queue(&Queue::new()).unwrap();
12 let submitter = pool.task_submitter(qid).unwrap();
13
14 // Step#3. create tasks
15
16 // an indepent task
17 let task = (|| println!("task='free': Hello, 1 2 3 ..")).into_task();
18 let _ = submitter.submit(task);
19
20 // an exit task with cond(#0 i32, #1 str)
21 let exit = submitter
22 .submit(
23 (|a: i32, msg: &str| println!("task='exit': received ({a},{msg:?}) and EXIT"))
24 .into_exit_task(),
25 )
26 .take();
27
28 // N->1 : pass i32 to exit-task.p0
29 let b1 = (|a: i32| {
30 println!("task='B1': pass ('{a}') to task='exit'");
31 a
32 })
33 .into_task()
34 .bind_to(exit.input_ca::<0>());
35 let b1 = submitter.submit(b1).take();
36
37 // N->1 : pass str to exit task.p1
38 let b2 = (|msg: &'static str| {
39 println!("task='B2': recv ('{msg}') and then pass ('{msg}') to task='exit'");
40 msg
41 })
42 .into_task()
43 .bind_to(exit.input_ca::<1>());
44 let b2 = submitter.submit(b2).take();
45
46 // 1->N : map result to task-b1 and task-b2
47 let b3 = (||())
48 .into_task()
49 .map_tuple_with(move |_: ()| {
50 println!("task='A': map `()=>(i32,&str)` and then pass (10,'exit') to task=['B1','B2']");
51 (10, "exit")
52 })
53 .bind_all_to((b1.input_ca::<0>(), b2.input_ca::<0>()));
54 let _ = submitter.submit(b3);
55
56 // Step#4. start a thread and run
57 pool.spawn_thread_for(qid);
58
59 // Step#5. wait until all finished
60 pool.join();
61}Trait Implementations§
Auto Trait Implementations§
impl<Ps> Freeze for Submission<Ps>
impl<Ps> RefUnwindSafe for Submission<Ps>where
Ps: RefUnwindSafe,
impl<Ps> Send for Submission<Ps>where
Ps: Send,
impl<Ps> Sync for Submission<Ps>where
Ps: Sync,
impl<Ps> Unpin for Submission<Ps>where
Ps: Unpin,
impl<Ps> UnsafeUnpin for Submission<Ps>
impl<Ps> UnwindSafe for Submission<Ps>where
Ps: UnwindSafe,
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