Objectively
Ultra-lightweight object oriented framework for GNU C.
Loading...
Searching...
No Matches
Lock.h File Reference

POSIX Threads locks. More...

Go to the source code of this file.

Data Structures

struct  Lock
 POSIX Threads locks. More...
 

Macros

#define synchronized(_lock, statements)
 Wraps statements with calls to lock and unlock.
 

Functions

OBJECTIVELY_EXPORT Class_Lock (void)
 

Detailed Description

POSIX Threads locks.

Definition in file Lock.h.

Macro Definition Documentation

◆ synchronized

#define synchronized (   _lock,
  statements 
)
Value:
{ \
$((Lock *) _lock, lock); \
statements; \
$((Lock *) _lock, unlock); \
}
static void unlock(Lock *self)
Definition Lock.c:103
static void lock(Lock *self)
Definition Lock.c:81
POSIX Threads locks.
Definition Lock.h:42

Wraps statements with calls to lock and unlock.

Parameters
_lockThe Lock instance.
statementsThe statements to perform while the Lock is held.

Definition at line 120 of file Lock.h.

120 { \
121 $((Lock *) _lock, lock); \
122 statements; \
123 $((Lock *) _lock, unlock); \
124}

Function Documentation

◆ _Lock()

OBJECTIVELY_EXPORT Class * _Lock ( void  )

Definition at line 129 of file Lock.c.

129 {
130 static Class *clazz;
131 static Once once;
132
133 do_once(&once, {
134 clazz = _initialize(&(const ClassDef) {
135 .name = "Lock",
136 .superclass = _Object(),
137 .instanceSize = sizeof(Lock),
138 .interfaceOffset = offsetof(Lock, interface),
139 .interfaceSize = sizeof(LockInterface),
141 });
142 });
143
144 return clazz;
145}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
Definition Class.c:86
static void initialize(Class *clazz)
Definition Lock.c:114
Class * _Object(void)
Definition Object.c:136
long Once
The Once type.
Definition Once.h:37
#define do_once(once, block)
Executes the given block at most one time.
Definition Once.h:43
ClassDefs are passed to _initialize via an archetype to initialize a Class.
Definition Class.h:41
The runtime representation of a Class.
Definition Class.h:95