#tetcoin #framework #blockchain #crypto

no-std tp-tasks

Runtime asynchronous, pure computational tasks

Show the crate…

2 stable releases

2.0.1 Apr 3, 2021
2.0.0 Apr 2, 2021

#42 in #tetcore

Download history 55/week @ 2023-12-07 60/week @ 2023-12-14 67/week @ 2023-12-21 22/week @ 2023-12-28 51/week @ 2024-01-04 74/week @ 2024-01-11 41/week @ 2024-01-18 39/week @ 2024-01-25 24/week @ 2024-02-01 51/week @ 2024-02-08 77/week @ 2024-02-15 69/week @ 2024-02-22 74/week @ 2024-02-29 97/week @ 2024-03-07 60/week @ 2024-03-14 78/week @ 2024-03-21

320 downloads per month
Used in 54 crates (2 directly)

Apache-2.0

385KB
7K SLoC

Runtime asynchronous, pure computational tasks.

License: Apache-2.0


lib.rs:

Runtime tasks.

Contains runtime-usable functions for spawning parallel purely computational tasks.

NOTE: This is experimental API. NOTE: When using in actual runtime, make sure you don't produce unbounded parallelism. So this is bad example to use it:

   fn my_parallel_computator(data: Vec<u8>) -> Vec<u8> {
       unimplemented!()
   }
   fn test(dynamic_variable: i32) {
       for _ in 0..dynamic_variable { tp_tasks::spawn(my_parallel_computator, vec![]); }
   }

While this is a good example:

   use codec::Encode;
   static STATIC_VARIABLE: i32 = 4;

   fn my_parallel_computator(data: Vec<u8>) -> Vec<u8> {
       unimplemented!()
   }

   fn test(computation_payload: Vec<u8>) {
       let parallel_tasks = (0..STATIC_VARIABLE).map(|idx|
           tp_tasks::spawn(my_parallel_computator, computation_payload.chunks(10).nth(idx as _).encode())
       );
   }

When allowing unbounded parallelism, malicious transactions can exploit it and partition network consensus based on how much resources nodes have.

Dependencies

~3–12MB
~122K SLoC