Stream: jco

Topic: ✔ implementing advisory locks


view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:31):

Hey, I was just looking at the file locking APIs in WIT together with @Wassim Chegham - and we think it's not going to be straight forward.

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:33):

So for Rust we have my fd-lock crate which is implemented like a Mutex. You can either call a lock method which will block until the lock has been released. Or you can call the try_lock variants which immediately return a Result indicating whether it was possible to take a lock out.

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:34):

The JS version of this crate is the fd-lock package which I based the Rust fd-lock crate on.

Advisory cross-platform lock on a file using a file descriptor to it.. Latest version: 1.2.0, last published: 3 years ago. Start using fd-lock in your project by running `npm i fd-lock`. There are 20 other projects in the npm registry using fd-lock.

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:35):

However one issue with that is that it only provides the equivalent try_ versions. It does not provide a way to block until the lock has been released. And Node.js does not have generalized "block until some action" tooling that we can use for this.

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:36):

Maybe there's a way we could swing this using LibUV APIs, or maybe atomics. But honestly: I've already heard people talk about removing file locking from the current Preview 2 conformance target. And I think that would be my preferred route to take here.

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:37):

cc/ @Pat Hickey - I think you mentioned dropping file locking before. Do you have any thoughts on removing it from the current Preview 2 target?

view this post on Zulip Pat Hickey (Nov 08 2023 at 16:54):

file locking is officially dropped from p2

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:54):

oh greattttt!

view this post on Zulip Pat Hickey (Nov 08 2023 at 16:54):

https://github.com/WebAssembly/wasi-filesystem/pull/136

We believe there is value in these lock methods for some applications (e.g. sqlite), but for the sake of shipping Preview 2, we don't have time to make and test a cross platform implementation of t...

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:54):

ohhh, I think what happened is that I didn't update the issues on GitHub to reflect the updated APIs

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:54):

I should do another pass on those

view this post on Zulip Pat Hickey (Nov 08 2023 at 16:54):

yep. np

view this post on Zulip Yoshua Wuyts (Nov 08 2023 at 16:55):

ty ty ^^

view this post on Zulip Notification Bot (Nov 08 2023 at 16:55):

Yoshua Wuyts has marked this topic as resolved.


Last updated: Nov 22 2024 at 17:03 UTC