mirror of
https://github.com/Drop-OSS/droplet.git
synced 2025-11-17 02:01:19 +10:00
async utils that might fix my problem
This commit is contained in:
@ -1,14 +1,17 @@
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
path::Path,
|
||||
path::Path, thread,
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
use gxhash::gxhash128;
|
||||
use napi::{Error, JsFunction, JsNumber};
|
||||
use napi::{
|
||||
threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode},
|
||||
Error, JsFunction,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use serde_json::json;
|
||||
use uuid::Uuid;
|
||||
@ -26,6 +29,19 @@ struct Chunk {
|
||||
checksum: String,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn call_alt_thread_func(callback: JsFunction) -> Result<(), Error> {
|
||||
let tsfn: ThreadsafeFunction<u32, ErrorStrategy::CalleeHandled> = callback
|
||||
.create_threadsafe_function(0, |ctx| {
|
||||
ctx.env.create_uint32(ctx.value + 1).map(|v| vec![v])
|
||||
})?;
|
||||
let tsfn = tsfn.clone();
|
||||
thread::spawn(move || {
|
||||
tsfn.call(Ok(0), ThreadsafeFunctionCallMode::Blocking);
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn generate_manifest(
|
||||
dir: String,
|
||||
|
||||
Reference in New Issue
Block a user