106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
OFThread *currentThread = [OFThread currentThread];
OFRunLoop *runLoop = [currentThread runLoop];
if (runLoop != nil)
return runLoop;
runLoop = [[[OFRunLoop alloc] init] autorelease];
[currentThread _setRunLoop: runLoop];
return runLoop;
}
+ (void)_setMainRunLoop
{
void *pool = objc_autoreleasePoolPush();
mainRunLoop = [[[OFThread currentThread] runLoop] retain];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_BLOCKS
+ (void)_addAsyncReadForStream: (OFStream*)stream
buffer: (void*)buffer
length: (size_t)length
block: (of_stream_async_read_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [self currentRunLoop];
OFList *queue = [runLoop->readQueues objectForKey: stream];
|
|
|
|
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
OFThread *currentThread = [OFThread currentThread];
OFRunLoop *runLoop = [currentThread runLoop];
if (runLoop != nil)
return runLoop;
runLoop = [[[OFRunLoop alloc] init] autorelease];
[currentThread OF_setRunLoop: runLoop];
return runLoop;
}
+ (void)OF_setMainRunLoop
{
void *pool = objc_autoreleasePoolPush();
mainRunLoop = [[[OFThread currentThread] runLoop] retain];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_BLOCKS
+ (void)OF_addAsyncReadForStream: (OFStream*)stream
buffer: (void*)buffer
length: (size_t)length
block: (of_stream_async_read_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [self currentRunLoop];
OFList *queue = [runLoop->readQueues objectForKey: stream];
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
[queueItem setLength: length];
[queueItem setBlock: block];
[queue appendObject: queueItem];
objc_autoreleasePoolPop(pool);
}
+ (void)_addAsyncReadLineForStream: (OFStream*)stream
encoding: (of_string_encoding_t)encoding
block: (of_stream_async_read_line_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [self currentRunLoop];
OFList *queue = [runLoop->readQueues objectForKey: stream];
OFRunLoop_ReadLineQueueItem *queueItem;
if (queue == nil) {
|
|
|
|
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
[queueItem setLength: length];
[queueItem setBlock: block];
[queue appendObject: queueItem];
objc_autoreleasePoolPop(pool);
}
+ (void)OF_addAsyncReadLineForStream: (OFStream*)stream
encoding: (of_string_encoding_t)encoding
block: (of_stream_async_read_line_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [self currentRunLoop];
OFList *queue = [runLoop->readQueues objectForKey: stream];
OFRunLoop_ReadLineQueueItem *queueItem;
if (queue == nil) {
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
[queueItem setBlock: block];
[queueItem setEncoding: encoding];
[queue appendObject: queueItem];
objc_autoreleasePoolPop(pool);
}
+ (void)_addAsyncAcceptForTCPSocket: (OFTCPSocket*)socket
block: (of_tcpsocket_async_accept_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [self currentRunLoop];
OFList *queue = [runLoop->readQueues objectForKey: socket];
OFRunLoop_AcceptQueueItem *queueItem;
if (queue == nil) {
|
|
|
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
[queueItem setBlock: block];
[queueItem setEncoding: encoding];
[queue appendObject: queueItem];
objc_autoreleasePoolPop(pool);
}
+ (void)OF_addAsyncAcceptForTCPSocket: (OFTCPSocket*)socket
block: (of_tcpsocket_async_accept_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [self currentRunLoop];
OFList *queue = [runLoop->readQueues objectForKey: socket];
OFRunLoop_AcceptQueueItem *queueItem;
if (queue == nil) {
|