mirror of
https://github.com/fuse-friends/fuse-native
synced 2024-10-27 18:34:01 +00:00
add simple way of messaging numbers and return code
This commit is contained in:
parent
48d991ac79
commit
5a2c2b5d03
@ -28,7 +28,8 @@ typedef struct {
|
||||
} fuse_thread_t;
|
||||
|
||||
typedef struct {
|
||||
int hello;
|
||||
uint32_t ints[32];
|
||||
int32_t res;
|
||||
fuse_thread_t *fuse;
|
||||
fuse_native_semaphore_t sem;
|
||||
uv_async_t async;
|
||||
@ -39,18 +40,6 @@ typedef struct {
|
||||
|
||||
static pthread_key_t thread_locals_key;
|
||||
|
||||
// static fuse_thread_locals_t * thread_local_map[1024];
|
||||
// static int thread_local_map_length = 0;
|
||||
|
||||
// static int get_free_thread_id () {
|
||||
// for (int i = 0; i < thread_local_map_length; i++) {
|
||||
// if (thread_local_map[i] == NULL) return i;
|
||||
// }
|
||||
|
||||
// return thread_local_map_length++;
|
||||
// }
|
||||
|
||||
|
||||
static void fin (napi_env env, void *fin_data, void* fin_hint) {
|
||||
printf("finaliser is run\n");
|
||||
// exit(0);
|
||||
@ -91,8 +80,6 @@ static fuse_thread_locals_t* get_thread_locals () {
|
||||
|
||||
fuse_thread_locals_t* l = (fuse_thread_locals_t *) malloc(sizeof(fuse_thread_locals_t));
|
||||
|
||||
l->hello = 42;
|
||||
|
||||
// TODO: mutex me??
|
||||
int err = uv_async_init(uv_default_loop(), &(l->async), (uv_async_cb) fuse_native_dispatch);
|
||||
|
||||
@ -138,14 +125,23 @@ static int fuse_native_getattr (const char *path, struct stat *stat) {
|
||||
uv_async_send(&(l->async));
|
||||
fuse_native_semaphore_wait(&(l->sem));
|
||||
|
||||
printf("l->res: %i\n", l->res);
|
||||
printf("l->ints[0]: %u\n", l->ints[0]);
|
||||
printf("l->ints[1]: %u\n", l->ints[1]);
|
||||
printf("l->ints[2]: %u\n", l->ints[2]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
NAPI_METHOD(fuse_native_signal) {
|
||||
NAPI_ARGV(5)
|
||||
NAPI_ARGV(2)
|
||||
NAPI_ARGV_BUFFER_CAST(fuse_thread_locals_t *, l, 0);
|
||||
NAPI_ARGV_INT32(res, 1)
|
||||
|
||||
l->res = res;
|
||||
fuse_native_semaphore_signal(&(l->sem));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NAPI_METHOD(fuse_native_mount) {
|
||||
|
9
index.js
9
index.js
@ -12,9 +12,14 @@ class Fuse {
|
||||
}
|
||||
|
||||
onop (handle) {
|
||||
console.log('on_op is called', handle)
|
||||
const ints = new Uint32Array(handle.buffer, handle.byteOffset, 32)
|
||||
|
||||
ints[0] = 1
|
||||
ints[1] = 42
|
||||
ints[2] = 10
|
||||
|
||||
process.nextTick(function () {
|
||||
binding.fuse_native_signal(handle)
|
||||
binding.fuse_native_signal(handle, -1)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user