28#define _Class _OperationQueue
47 $(this->locals.thread,
cancel);
48 $(this->locals.thread,
join, NULL);
51 release(this->locals.condition);
52 release(this->locals.operations);
57#pragma mark - OperationQueue
131 const Time interval = { .tv_usec = 10 };
160 assert(self->locals.
thread);
228#pragma mark - Class lifecycle
258 .name =
"OperationQueue",
262 .interfaceSize =
sizeof(OperationQueueInterface),
ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
struct timeval Time
Time (seconds and microseconds).
static __thread OperationQueue * _currentQueue
static ident run(Thread *thread)
ThreadFunction for the OperationQueue Thread.
static void initialize(Class *clazz)
OperationQueues provide a thread of execution for Operations.
void * ident
The identity type, similar to Objective-C id.
#define do_once(once, block)
Executes the given block at most one time.
ident objectAtIndex(const Array *self, int index)
size_t count
The count of elements.
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.
POSIX Threads conditional variables.
void wait(Condition *self)
Waits indefinitely for this Condition to be signaled.
_Bool waitUntilDate(Condition *self, const Date *date)
Waits until the specified Date for this Condition to be signaled.
Condition * init(Condition *self)
Initializes this Condition.
void broadcast(Condition *self)
Signals all Threads waiting on this Condition.
Microsecond-precision immutable dates.
Date * dateWithTimeSinceNow(const Time interval)
Returns a new Date with the given Time since now.
Date * date(void)
Returns a new Date with the current Time.
void addObject(MutableArray *self, const ident obj)
Adds the specified Object to this MutableArray.
void removeObject(MutableArray *self, const ident obj)
Removes the specified Object from this MutableArray.
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.
An abstraction for discrete units of work, or tasks.
_Bool isReady(const Operation *self)
void start(Operation *self)
Starts this Operation.
_Bool isCancelled
true when this Operation has been cancelled, false otherwise.
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.
_Bool isExecuting
true when this Operation is executing, false otherwise.
_Bool isFinished
true when this Operation is finished, false otherwise.
OperationQueues provide a thread of execution for Operations.
Class * _OperationQueue(void)
The OperationQueue archetype.
OperationQueue * currentQueue(void)
_Bool isSuspended
When true, the queue will not start any new Operations.
void removeOperation(OperationQueue *self, Operation *operation)
Removes the Operation from this queue.
void cancelAllOperations(OperationQueue *self)
Cancels all pending Operations residing within this Queue.
size_t operationCount(const OperationQueue *self)
Thread * thread
The backing Thread.
OperationQueue * init(OperationQueue *self)
Initializes this OperationQueue.
void waitUntilAllOperationsAreFinished(OperationQueue *self)
Waits until all Operations submitted to this queue have finished.
Condition * condition
A condition signaled on addOperation and removeOperation.
void addOperation(OperationQueue *self, Operation *operation)
Adds an Operation to this queue.
Array * operations(const OperationQueue *self)
MutableArray * operations
The Operations.
void join(Thread *self, ident *status)
Wait for the specified Thread to terminate.
_Bool isCancelled
true when this Thread has been cancelled, false otherwise.