mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: cleanup APIs returning !bool
to either return !
or bool
(#16111)
This commit is contained in:
@ -15,17 +15,15 @@ pub fn (mut l FileLock) unlink() {
|
||||
C.DeleteFileW(t_wide)
|
||||
}
|
||||
|
||||
pub fn (mut l FileLock) acquire() !bool {
|
||||
pub fn (mut l FileLock) acquire() ! {
|
||||
if l.fd != -1 {
|
||||
// lock already acquired by this instance
|
||||
return false
|
||||
return error_with_code('lock already acquired by this instance', 1)
|
||||
}
|
||||
fd := open(l.name)
|
||||
if fd == -1 {
|
||||
return error('cannot create lock file $l.name')
|
||||
return error_with_code('cannot create lock file $l.name', -1)
|
||||
}
|
||||
l.fd = fd
|
||||
return true
|
||||
}
|
||||
|
||||
pub fn (mut l FileLock) release() bool {
|
||||
@ -39,7 +37,7 @@ pub fn (mut l FileLock) release() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
pub fn (mut l FileLock) wait_acquire(s int) !bool {
|
||||
pub fn (mut l FileLock) wait_acquire(s int) bool {
|
||||
fin := time.now().add(s)
|
||||
for time.now() < fin {
|
||||
if l.try_acquire() {
|
||||
|
Reference in New Issue
Block a user