Remove sp_tasks::spawn API and related code + host functions (#12639)

* Remove `sp_tasks::spawn` API and related code

* Remove `RuntimeTasks::{spawn, join}` host functions

* remove unused

* Remove a few more tests that I forgot to remove

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Koute
2022-11-10 21:23:56 +09:00
committed by GitHub
parent 9979acb1e7
commit 5c7ec6909d
18 changed files with 10 additions and 1147 deletions
@@ -318,24 +318,6 @@ sp_core::wasm_export_functions! {
message_slice.copy_from_slice(test_message);
}
fn test_spawn() {
let data = vec![1u8, 2u8];
let data_new = sp_tasks::spawn(tasks::incrementer, data).join();
assert_eq!(data_new, vec![2u8, 3u8]);
}
fn test_nested_spawn() {
let data = vec![7u8, 13u8];
let data_new = sp_tasks::spawn(tasks::parallel_incrementer, data).join();
assert_eq!(data_new, vec![10u8, 16u8]);
}
fn test_panic_in_spawned() {
sp_tasks::spawn(tasks::panicker, vec![]).join();
}
fn test_return_i8() -> i8 {
-66
}
@@ -358,25 +340,6 @@ sp_core::wasm_export_functions! {
}
}
#[cfg(not(feature = "std"))]
mod tasks {
use sp_std::prelude::*;
pub fn incrementer(data: Vec<u8>) -> Vec<u8> {
data.into_iter().map(|v| v + 1).collect()
}
pub fn panicker(_: Vec<u8>) -> Vec<u8> {
panic!()
}
pub fn parallel_incrementer(data: Vec<u8>) -> Vec<u8> {
let first = data.into_iter().map(|v| v + 2).collect::<Vec<_>>();
let second = sp_tasks::spawn(incrementer, first).join();
second
}
}
/// A macro to define a test entrypoint for each available sandbox executor.
macro_rules! wasm_export_sandbox_test_functions {
(