Skip to content

Commit

Permalink
std/os: use lightweight runtime mutex instead of sync::Mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Feb 19, 2025
1 parent d799c97 commit 1631032
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions std/os/path_windows.jule
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use integ "std/jule/integrated"
use "std/os/filepath"
use "std/os/internal"
use "std/os/internal/windows"
use "std/sync"
use "std/runtime"
use "std/sys"

// Working directory cache.
// It used by the addExtendedPrefix function.
static mut wd = ""
static wdmu = new(sync::Mutex)
static wdmu = runtime::fmutex{}

// Returns the extended-length (\\?\-prefixed) form of
// path when needed, in order to avoid the default 260 character file
Expand Down Expand Up @@ -64,13 +64,13 @@ fn addExtendedPrefix(path: str): str {
// Note that getwdCache might be outdated if the working directory has been
// changed without using os::Chdir, i.e. using sys::Chdir equivalent directly or Integrated Jule.
// This is fine, as the worst that can happen is that we fail to fix the path.
wdmu.Lock()
wdmu.lock()
if wd == "" {
// Init the working directory cache.
wd = internal::Getwd()
}
pathLength += len(wd) + 1
wdmu.Unlock()
wdmu.unlock()
}

if pathLength < 248 {
Expand Down
4 changes: 2 additions & 2 deletions std/os/proc.jule
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ fn Chdir(path: str)! {
const match runtime::OS {
| "windows":
abs := filepath::IsAbs(path)
wdmu.Lock()
wdmu.lock()
if abs {
wd = path
} else {
wd = ""
}
wdmu.Unlock()
wdmu.unlock()
}
}

Expand Down

0 comments on commit 1631032

Please sign in to comment.