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
146 const Time interval = { .tv_usec = 10 };
175 assert(self->locals.
thread);
241#pragma mark - Class lifecycle
272 .name =
"OperationQueue",
276 .interfaceSize =
sizeof(OperationQueueInterface),
static ident objectAtIndex(const Array *self, size_t index)
static void removeObject(Array *self, const ident obj)
static void addObject(Array *self, const ident obj)
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,...)
static void broadcast(Condition *self)
static bool waitUntilDate(Condition *self, const Date *date)
static Date * dateWithTimeSinceNow(const Time *interval)
struct timeval Time
Time (seconds and microseconds).
static Operation * initWithFunction(Operation *self, OperationFunction function, ident data)
static void start(Operation *self)
static void cancel(Operation *self)
static bool isReady(const Operation *self)
void(* OperationFunction)(Operation *operation)
The function type for Operation execution.
Class * _OperationQueue(void)
static void removeOperation(OperationQueue *self, Operation *operation)
static size_t operationCount(const OperationQueue *self)
static OperationQueue * currentQueue(void)
static void addOperation(OperationQueue *self, Operation *operation)
static void waitUntilAllOperationsAreFinished(OperationQueue *self)
static Operation * addOperationWithFunction(OperationQueue *self, OperationFunction function, ident data)
static __thread OperationQueue * _currentQueue
static void cancelAllOperations(OperationQueue *self)
static ident run(Thread *thread)
ThreadFunction for the OperationQueue Thread.
static OperationQueue * init(OperationQueue *self)
static Array * operations(const OperationQueue *self)
static void dealloc(Object *self)
static Object * copy(const Object *self)
static void initialize(Class *clazz)
OperationQueues provide a thread of execution for Operations.
static void join(Thread *self, ident *status)
void * ident
The identity type, similar to Objective-C id.
#define do_once(once, block)
Executes the given block at most one time.
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.
Microsecond-precision immutable dates.
Object is the root Class of The Objectively Class hierarchy.
void dealloc(Object *self)
Frees all resources held by this Object.
An abstraction for discrete units of work, or tasks.
bool isCancelled
true when this Operation has been cancelled, false otherwise.
bool isFinished
true when this Operation is finished, false otherwise.
bool isExecuting
true when this Operation is executing, false otherwise.
OperationQueues provide a thread of execution for Operations.
size_t operationCount(const OperationQueue *self)
Thread * thread
The backing Thread.
OperationQueue * init(OperationQueue *self)
Initializes this OperationQueue.
bool isSuspended
When true, the queue will not start any new Operations.
Array * operations
The Operations.
Condition * condition
A condition signaled on addOperation and removeOperation.
bool isCancelled
true when this Thread has been cancelled, false otherwise.