50 pthread_mutex_destroy(this->
lock);
67 self->lock = calloc(1,
sizeof(pthread_mutex_t));
70 const int err = pthread_mutex_init(self->lock, NULL);
83 int err = pthread_mutex_lock(self->lock);
93 int err = pthread_mutex_trylock(self->lock);
94 assert(err == 0 || err == EBUSY);
105 int err = pthread_mutex_unlock(self->lock);
109#pragma mark - Class lifecycle
137 .instanceSize =
sizeof(
Lock),
138 .interfaceOffset = offsetof(
Lock, interface),
139 .interfaceSize =
sizeof(LockInterface),
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define super(type, obj, method,...)
static void initialize(Class *clazz)
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
ident interface
The interface of the Class.
Condition * init(Condition *self)
Initializes this Condition.
Class * _Lock(void)
The Lock archetype.
_Bool tryLock(Lock *self)
Attempt to acquire this lock immediately.
void lock(Lock *self)
Acquire this lock, waiting indefinitely.
void unlock(Lock *self)
Release this Lock.
Object is the root Class of The Objectively Class hierarchy.
Class * _Object(void)
The Object archetype.
Object * copy(const Object *self)
Creates a shallow copy of this Object.
void dealloc(Object *self)
Frees all resources held by this Object.