ObjFW  Diff

Differences From Artifact [dcfb0c9b58]:

To Artifact [1b7b5d2a56]:


33
34
35
36
37
38
39
40

41
42
43
44
45
46
47

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
33
34
35
36
37
38
39

40

41
42
43
44
45

46

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

63
64

65

66
67
68
69
70
71
72







-
+
-





-
+
-
















-


-
+
-







#endif
}

+ jobWithTarget: (id)target
       selector: (SEL)selector
	 object: (id)object;
#ifdef OF_HAVE_BLOCKS
+ jobWithBlock: (of_thread_pool_block_t)block
+ jobWithBlock: (of_thread_pool_block_t)block;
	object: (id)object;
#endif
- initWithTarget: (id)target
	selector: (SEL)selector
	  object: (id)object;
#ifdef OF_HAVE_BLOCKS
- initWithBlock: (of_thread_pool_block_t)block
- initWithBlock: (of_thread_pool_block_t)block;
	 object: (id)object;
#endif
- (void)perform;
@end

@implementation OFThreadPoolJob
+ jobWithTarget: (id)target
       selector: (SEL)selector
	 object: (id)object
{
	return [[[self alloc] initWithTarget: target
				    selector: selector
				      object: object] autorelease];
}

#ifdef OF_HAVE_BLOCKS
+ jobWithBlock: (of_thread_pool_block_t)block
	object: (id)object
{
	return [[(OFThreadPoolJob*)[self alloc]
	    initWithBlock: block
	    initWithBlock: block] autorelease];
		   object: object] autorelease];
}
#endif

- initWithTarget: (id)target_
	selector: (SEL)selector_
	  object: (id)object_
{
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
82
83
84
85
86
87
88

89
90
91
92
93

94
95
96
97
98
99
100







-





-







	}

	return self;
}

#ifdef OF_HAVE_BLOCKS
- initWithBlock: (of_thread_pool_block_t)block_
	 object: (id)object_
{
	self = [super init];

	@try {
		block = [block_ copy];
		object = [object_ retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125







-
+







	[super dealloc];
}

- (void)perform
{
#ifdef OF_HAVE_BLOCKS
	if (block != NULL)
		block(object);
		block();
	else
#endif
		[object performSelector: selector
			     withObject: object];
}
@end

369
370
371
372
373
374
375
376

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
363
364
365
366
367
368
369

370








371
372
373
374
375
376
377
378







-
+
-
-
-
-
-
-
-
-








						    selector: selector
						      object: object]];
}

#ifdef OF_HAVE_BLOCKS
- (void)dispatchWithBlock: (of_thread_pool_block_t)block
{
	[self OF_dispatchJob: [OFThreadPoolJob jobWithBlock: block
	[self OF_dispatchJob: [OFThreadPoolJob jobWithBlock: block]];
						     object: nil]];
}

- (void)dispatchWithBlock: (of_thread_pool_block_t)block
		   object: (id)object
{
	[self OF_dispatchJob: [OFThreadPoolJob jobWithBlock: block
						     object: object]];
}
#endif

- (size_t)size
{
	return size;
}
@end