Skip to content

Refactor file lock#17105

Open
ysbaddaden wants to merge 1 commit into
crystal-lang:masterfrom
ysbaddaden:refactor/flock
Open

Refactor file lock#17105
ysbaddaden wants to merge 1 commit into
crystal-lang:masterfrom
ysbaddaden:refactor/flock

Conversation

@ysbaddaden

Copy link
Copy Markdown
Collaborator

Simplifies the system interface:

  • #system_lock(blocking, exclusive)
  • #system_unlock

Refactors the algorithm to leverage Fiber.syscall when available instead of polling.

The first attempt is always non-blocking, then further attempts will be blocking with execution contexts or non-blocking with regular polling for the legacy runtimes (without_mt, preview_mt).

On Windows, when the file handle has been opened with the OVERLAPPED flag, we use an overlapped operations when blocking, and otherwise fallback to the algorithm described above.

The first attempt is always non-blocking, then further attempts will be
blocking with execution contexts or non-blocking with regular polling
for the legacy runtimes (without_mt, preview_mt).

On Windows, when the file handle has been opened with the OVERLAPPED
flag, we use an overlapped operations when blocking, and otherwise
fallback to the algorithm described above.

Also simpligies the system interface:

- #system_lock(blocking, exclusive)
- #system_unlock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

1 participant