@@ -14,7 +14,11 @@ private func logInfo(_ message: String) {
1414}
1515#else
1616private func logInfo( _ message: String ) {
17- fputs ( " [FileLock] \( message) \n " , stderr)
17+ // Use fd 2 directly to avoid concurrency warning on `stderr` global variable
18+ let line = " [FileLock] \( message) \n "
19+ line. utf8. withContiguousStorageIfAvailable { buffer in
20+ _ = write ( 2 , buffer. baseAddress, buffer. count)
21+ }
1822}
1923#endif
2024
@@ -549,7 +553,7 @@ public final class FileLock: Sendable {
549553 // for ownership tracking. Non-owning tasks should NOT affect the counter.
550554 // The counter is set to 1 on successful acquisition via recordAcquisition.
551555 let fd = try openLockFile ( )
552- let startTime = CFAbsoluteTimeGetCurrent ( )
556+ let startTime = Date ( ) . timeIntervalSinceReferenceDate
553557
554558 var attempt = 0
555559 do {
@@ -577,7 +581,7 @@ public final class FileLock: Sendable {
577581
578582 // Check if we've exceeded max retries (nil means infinite)
579583 if let max = maxRetries, attempt >= max {
580- let elapsed = CFAbsoluteTimeGetCurrent ( ) - startTime
584+ let elapsed = Date ( ) . timeIntervalSinceReferenceDate - startTime
581585 throw FileLockError . acquisitionFailed (
582586 lockPath,
583587 attempts: attempt + 1 ,
@@ -587,7 +591,7 @@ public final class FileLock: Sendable {
587591
588592 // Log progress periodically
589593 if attempt > 0 , attempt % Self. logInterval == 0 {
590- let elapsed = CFAbsoluteTimeGetCurrent ( ) - startTime
594+ let elapsed = Date ( ) . timeIntervalSinceReferenceDate - startTime
591595 logInfo ( " Waiting for lock on \( self . lockPath. lastPathComponent) (elapsed: \( String ( format: " %.1f " , elapsed) ) s) " )
592596 }
593597
0 commit comments