Objectively
Object oriented framework for C.
Loading...
Searching...
No Matches
Operation.h
Go to the documentation of this file.
1/*
2 * Objectively: Ultra-lightweight object oriented framework for GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/Array.h>
28#include <Objectively/Object.h>
29#include <Objectively/Thread.h>
30
36typedef struct Operation Operation;
37typedef struct OperationInterface OperationInterface;
38
39typedef struct OperationQueue OperationQueue;
40
45typedef void (*OperationFunction)(Operation *operation);
46
53struct Operation {
54
59
64 OperationInterface *interface[0];
65
71
76 Condition *condition;
77
82
87 Array *dependencies;
88
93
100 bool isCancelled;
101
107
112
117
125 OperationQueue *queue;
126};
127
131struct OperationInterface {
132
136 ObjectInterface objectInterface;
137
145 void (*addDependency)(Operation *self, Operation *dependency);
146
155 void (*cancel)(Operation *self);
156
163 Array *(*dependencies)(const Operation *self);
164
173 Operation *(*init)(Operation *self);
174
184 Operation *(*initWithFunction)(Operation *self, OperationFunction function, ident data);
185
194 bool (*isCancelled)(const Operation *self);
195
202 bool (*isReady)(const Operation *self);
203
211 void (*removeDependency)(Operation *self, Operation *dependency);
212
224 void (*start)(Operation *self);
225
232 void (*waitUntilFinished)(const Operation *self);
233};
234
Arrays.
POSIX Threads conditional variables.
static Data * data(void)
Definition Data.c:286
Object is the root Class of The Objectively Class hierarchy.
void(* OperationFunction)(Operation *operation)
The function type for Operation execution.
Definition Operation.h:45
OBJECTIVELY_EXPORT Class * _Operation(void)
Definition Operation.c:243
POSIX Threads.
void * ident
The identity type, similar to Objective-C id.
Definition Types.h:49
#define OBJECTIVELY_EXPORT
Definition Types.h:36
Arrays.
Definition Array.h:56
The runtime representation of a Class.
Definition Class.h:90
POSIX Threads conditional variables.
Definition Condition.h:44
Object is the root Class of The Objectively Class hierarchy.
Definition Object.h:46
An abstraction for discrete units of work, or tasks.
Definition Operation.h:53
ident data
The user data.
Definition Operation.h:81
bool isFinished
true when this Operation is finished, false otherwise.
Definition Operation.h:116
bool isDispatched
True once an OperationQueue has dispatched this Operation to one of its Threads, so that no other Thr...
Definition Operation.h:106
OperationInterface * interface[0]
The interface type.
Definition Operation.h:64
OperationFunction function
The Operation function.
Definition Operation.h:92
bool asynchronous
If true, this Operation will be expected to coordinate its own concurrency and internal state managem...
Definition Operation.h:70
Object object
The superclass.
Definition Operation.h:58
bool isExecuting
true when this Operation is executing, false otherwise.
Definition Operation.h:111
OperationQueues provide threads of execution for Operations.