ObjFW  Check-in [54e323d0c9]

Overview
Comment:Remove -[OFThreadPool dispatchWithBlock:object:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 54e323d0c984b5af6032709fa1e4b8e3469fb86e28f0f5a17fc402bcd4d6ceb9
User & Date: js on 2012-10-02 00:07:46
Other Links: manifest | tags
Context
2012-10-02
11:00
Clean up properties in exceptions. check-in: c7adbcf399 user: js tags: trunk
00:07
Remove -[OFThreadPool dispatchWithBlock:object:]. check-in: 54e323d0c9 user: js tags: trunk
00:04
Remove [OFThread initWithObject:block:]. check-in: 31ff715036 user: js tags: trunk
Changes

Modified src/OFThreadPool.h from [1c2b5c4b19] to [b5511b4c56].

13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27







-
+







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"

#ifdef OF_HAVE_BLOCKS
typedef void (^of_thread_pool_block_t)(id object);
typedef void (^of_thread_pool_block_t)(void);
#endif

@class OFMutableArray;
@class OFList;
@class OFCondition;
@class OFThreadPoolJob;

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
103
104
105
106
107
108
109









110
111
112
113
114
115
116







-
-
-
-
-
-
-
-
-







#ifdef OF_HAVE_BLOCKS
/**
 * \brief Executes the specified block as soon as a thread is ready.
 *
 * \param block The block to execute
 */
- (void)dispatchWithBlock: (of_thread_pool_block_t)block;

/**
 * \brief Executes the specified block as soon as a thread is ready.
 *
 * \param block The block to execute
 * \param object The object to pass to the block
 */
- (void)dispatchWithBlock: (of_thread_pool_block_t)block
		   object: (id)object;
#endif

/**
 * \brief Waits until all jobs are done.
 */
- (void)waitUntilDone;

Modified src/OFThreadPool.m from [dcfb0c9b58] to [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