51 assert(this->isExecuting ==
false);
93 int err = pthread_detach(*((pthread_t *) self->thread));
119 self->thread = calloc(1,
sizeof(pthread_t));
120 assert(self->thread);
132 int err = pthread_join(*((pthread_t *) self->thread), status);
142 int err = pthread_kill(*((pthread_t *) self->thread),
signal);
177 int err = pthread_create(self->thread, NULL,
run, self);
181#pragma mark - Class lifecycle
213 .instanceSize =
sizeof(
Thread),
214 .interfaceOffset = offsetof(
Thread, interface),
215 .interfaceSize =
sizeof(ThreadInterface),
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define super(type, obj, method,...)
static void _kill(Thread *self, int signal)
static ident run(ident obj)
Wraps the user-specified ThreadFunction, providing cleanup.
static __thread Thread * _currentThread
static void initialize(Class *clazz)
ident(* ThreadFunction)(Thread *thread)
The function type for Thread execution.
void * ident
The identity type, similar to Objective-C id.
#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.
void signal(Condition *self)
Signals a single Thread waiting on this Condition.
MutableData * data(void)
Returns a new MutableData.
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.
void start(Operation *self)
Starts this Operation.
void cancel(Operation *self)
Cancels this Operation, allowing it to complete immediately.
Operation * initWithFunction(Operation *self, OperationFunction function, ident data)
Initializes a synchronous Operation with the given function.
void join(Thread *self, ident *status)
Wait for the specified Thread to terminate.
ThreadFunction function
The Thread function.
Class * _Thread(void)
The Thread archetype.
_Bool isExecuting
true when this Thread is executing, false otherwise.
Thread * currentThread(void)
Returns the currently executing Thread.
_Bool isFinished
true when this Thread is finished, false otherwise.
_Bool isDetached
true when this Thread has been detached, false otherwise.
void detach(Thread *self)
Daemonize this Thread.
_Bool isCancelled
true when this Thread has been cancelled, false otherwise.