mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
636 B
Objective-C
47 lines
636 B
Objective-C
//
|
|
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import <SessionUtilitiesKit/UnfairLock.h>
|
|
#import <os/lock.h>
|
|
|
|
@implementation UnfairLock {
|
|
os_unfair_lock _lock;
|
|
}
|
|
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
_lock = OS_UNFAIR_LOCK_INIT;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)lock
|
|
{
|
|
os_unfair_lock_lock(&_lock);
|
|
}
|
|
|
|
- (void)unlock
|
|
{
|
|
os_unfair_lock_unlock(&_lock);
|
|
}
|
|
|
|
- (BOOL)tryLock
|
|
{
|
|
return os_unfair_lock_trylock(&_lock);
|
|
}
|
|
|
|
- (void)assertOwner
|
|
{
|
|
os_unfair_lock_assert_owner(&_lock);
|
|
}
|
|
|
|
- (void)assertNotOwner
|
|
{
|
|
os_unfair_lock_assert_not_owner(&_lock);
|
|
}
|
|
|
|
@end
|