Skip to content

Commit 79c83cd

Browse files
committed
Windows sleep.
1 parent e9ed4c1 commit 79c83cd

File tree

4 files changed

+3
-25
lines changed

4 files changed

+3
-25
lines changed

vfs/os_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func osLock(file *os.File, typ int16, start, len int64, timeout time.Duration, d
5656
if timeout < time.Since(before) {
5757
break
5858
}
59-
osSleep(time.Duration(rand.Int63n(int64(time.Millisecond))))
59+
time.Sleep(time.Duration(rand.Int63n(int64(time.Millisecond))))
6060
}
6161
}
6262
return osLockErrorCode(err, def)

vfs/os_std_sleep.go

Lines changed: 0 additions & 9 deletions
This file was deleted.

vfs/os_windows.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func osLock(file *os.File, flags, start, len uint32, timeout time.Duration, def
136136
if timeout < time.Since(before) {
137137
break
138138
}
139-
osSleep(time.Duration(rand.Int63n(int64(time.Millisecond))))
139+
time.Sleep(time.Duration(rand.Int63n(int64(time.Millisecond))))
140140
}
141141
}
142142
return osLockErrorCode(err, def)
@@ -171,16 +171,3 @@ func osLockErrorCode(err error, def _ErrorCode) _ErrorCode {
171171
}
172172
return def
173173
}
174-
175-
func osSleep(d time.Duration) {
176-
if d > 0 {
177-
period := max(1, d/(5*time.Millisecond))
178-
if period < 16 {
179-
windows.TimeBeginPeriod(uint32(period))
180-
}
181-
time.Sleep(d)
182-
if period < 16 {
183-
windows.TimeEndPeriod(uint32(period))
184-
}
185-
}
186-
}

vfs/vfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func vfsRandomness(ctx context.Context, mod api.Module, pVfs uint32, nByte int32
8383
}
8484

8585
func vfsSleep(ctx context.Context, mod api.Module, pVfs uint32, nMicro int32) _ErrorCode {
86-
osSleep(time.Duration(nMicro) * time.Microsecond)
86+
time.Sleep(time.Duration(nMicro) * time.Microsecond)
8787
return _OK
8888
}
8989

0 commit comments

Comments
 (0)