Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
Data Structures | Macros | Functions
Lock.h File Reference

POSIX Threads locks. More...

#include <Objectively/Object.h>

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. More...
 

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); \
}
POSIX Threads locks.
Definition: Lock.h:42
void lock(Lock *self)
Acquire this lock, waiting indefinitely.
Definition: Lock.c:81
void unlock(Lock *self)
Release this Lock.
Definition: Lock.c:103

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.

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:91
static void initialize(Class *clazz)
Definition: Lock.c:114
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
Class * _Object(void)
The Object archetype.
Definition: Object.c:136