chore(wasm): make build parallel

This commit is contained in:
Zixuan Chen 2022-12-08 20:01:06 +08:00
parent f9f556f822
commit b74ab34f79
4 changed files with 9 additions and 23 deletions

View file

@ -12,7 +12,6 @@ use std::{
marker::PhantomPinned,
sync::{Arc, Mutex, MutexGuard, RwLock},
};
use tracing::debug;
use fxhash::FxHashMap;
@ -351,7 +350,6 @@ impl LogStore {
self.reg.get_or_create_container_idx(container)
}
// TODO: this feels like a dumb way to bypass lifetime issue, but I don't have better idea right now :(
#[inline(always)]
pub(crate) fn with_hierarchy<F, R>(&mut self, f: F) -> R
where
@ -359,8 +357,7 @@ impl LogStore {
{
let h = self.hierarchy.clone();
let mut h = h.lock().unwrap();
let result = f(self, &mut h);
result
f(self, &mut h)
}
pub fn to_json(&self) -> LoroValue {

View file

@ -185,30 +185,20 @@ fn convert_encoded_to_changes(changes: EncodedClientChanges) -> Vec<Change<Remot
impl LoroCore {
#[instrument(skip_all)]
pub fn export_updates(&self, from: &VersionVector) -> Result<Vec<u8>, LoroError> {
debug!("Inner Export Updates");
match self.log_store.try_read() {
Ok(x) => {
debug!("get lock!");
x.export_updates(from)
}
Err(_) => {
debug!("failed to get lock Err");
Err(LoroError::LockError)
}
Ok(x) => x.export_updates(from),
Err(_) => Err(LoroError::LockError),
}
}
pub fn import_updates(&mut self, input: &[u8]) -> Result<(), LoroError> {
debug_log::group!("Import at {}", self.client_id());
let ans = self.log_store.write().unwrap().import_updates(input);
let ans = match ans {
match ans {
Ok(events) => {
self.notify(events);
Ok(())
}
Err(err) => Err(LoroError::DecodeError(err.to_string().into_boxed_str())),
};
debug_log::group_end!();
ans
}
}
}

View file

@ -1,4 +1,3 @@
use crate::event::Path;
use crate::LogStore;
use crate::{
container::registry::ContainerIdx,

View file

@ -30,9 +30,9 @@ async function build() {
return;
}
for (const target of TARGETS) {
await buildTarget(target);
}
await Promise.all(TARGETS.map(target => {
return buildTarget(target);
}));
console.log(
"✅",
@ -71,7 +71,7 @@ function genCommands(target: string): string[] {
return [
`rm -rf ./${target}`,
`wasm-bindgen --weak-refs --target ${target} --out-dir ${target} ../../target/wasm32-unknown-unknown/${target_dir}/loro_wasm.wasm`,
// ...(profile == "dev" ? [] : [`wasm-opt -O4 ${target}/loro_wasm_bg.wasm -o ${target}/loro_wasm_bg.wasm`]),
...(profile == "dev" ? [] : [`wasm-opt -O4 ${target}/loro_wasm_bg.wasm -o ${target}/loro_wasm_bg.wasm`]),
];
}