Skip to content

feature: Add new API Client::{try_acquire, support_try_acquire} for non-blocking operation #72

@NobodyXu

Description

@NobodyXu

On unix, when the named fifo is used and on Windows, it is possible to acquire without blocking.

For named fifo on unix, we can simply set pipe to be non-blocking before reading.

https://github.com/rust-lang/cc-rs/blob/2f587f5561fb9c3c02e5c9e186b2bea98691608a/src/parallel/job_token/unix.rs#L113

On windows, we can use WaitForSingleObject(self.sem, 0):

https://github.com/rust-lang/cc-rs/blob/2f587f5561fb9c3c02e5c9e186b2bea98691608a/src/parallel/job_token/windows.rs#L44

On Linux, we can also applies an optimization, to turn an annoymous pipe into a named fifo:

https://github.com/rust-lang/cc-rs/blob/2f587f5561fb9c3c02e5c9e186b2bea98691608a/src/parallel/job_token/unix.rs#L77

Though that optimization is verified to be incorrect on macOS, opening /dev/fd/$fd seems to return the same file description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions