21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include <errno.h>
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_SOCKETS
# import "OFKernelEventObserver.h"
#endif
#import "OFThread.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
# import "OFCondition.h"
#endif
#import "OFSortedList.h"
#import "OFTimer.h"
#import "OFTimer+Private.h"
#import "OFDate.h"
#import "OFObserveFailedException.h"
static OFRunLoop *mainRunLoop = nil;
#ifdef OF_HAVE_SOCKETS
@interface OFRunLoop_QueueItem: OFObject
{
@public
|
>
>
>
>
>
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <errno.h>
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_SOCKETS
# import "OFKernelEventObserver.h"
# import "OFTCPSocket.h"
# import "OFTCPSocket+Private.h"
#endif
#import "OFThread.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
# import "OFCondition.h"
#endif
#import "OFSortedList.h"
#import "OFTimer.h"
#import "OFTimer+Private.h"
#import "OFDate.h"
#import "OFObserveFailedException.h"
#ifdef OF_HAVE_SOCKETS
# import "OFConnectionFailedException.h"
#endif
static OFRunLoop *mainRunLoop = nil;
#ifdef OF_HAVE_SOCKETS
@interface OFRunLoop_QueueItem: OFObject
{
@public
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# ifdef OF_HAVE_BLOCKS
of_stream_async_write_block_t _block;
# endif
const void *_buffer;
size_t _length, _writtenLength;
}
@end
@interface OFRunLoop_AcceptQueueItem: OFRunLoop_QueueItem
{
@public
# ifdef OF_HAVE_BLOCKS
of_tcp_socket_async_accept_block_t _block;
# endif
|
>
>
>
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# ifdef OF_HAVE_BLOCKS
of_stream_async_write_block_t _block;
# endif
const void *_buffer;
size_t _length, _writtenLength;
}
@end
@interface OFRunLoop_ConnectQueueItem: OFRunLoop_QueueItem
@end
@interface OFRunLoop_AcceptQueueItem: OFRunLoop_QueueItem
{
@public
# ifdef OF_HAVE_BLOCKS
of_tcp_socket_async_accept_block_t _block;
# endif
|
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
{
[_block release];
[super dealloc];
}
# endif
@end
@implementation OFRunLoop_AcceptQueueItem
- (bool)handleObject: (id)object
{
OFTCPSocket *newSocket;
id exception = nil;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
{
[_block release];
[super dealloc];
}
# endif
@end
@implementation OFRunLoop_ConnectQueueItem
- (bool)handleObject: (id)object
{
id exception = nil;
int errNo;
void (*func)(id, SEL, OFTCPSocket *, id, id);
if ((errNo = [object of_socketError]) != 0)
exception = [OFConnectionFailedException
exceptionWithHost: nil
port: 0
socket: object
errNo: errNo];
func = (void (*)(id, SEL, OFTCPSocket *, id, id))
[_target methodForSelector: _selector];
func(_target, _selector, object, _context, exception);
return false;
}
@end
@implementation OFRunLoop_AcceptQueueItem
- (bool)handleObject: (id)object
{
OFTCPSocket *newSocket;
id exception = nil;
|
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
queueItem->_target = [target retain];
queueItem->_selector = selector;
queueItem->_context = [context retain];
queueItem->_buffer = buffer;
queueItem->_length = length;
})
}
+ (void)of_addAsyncAcceptForTCPSocket: (OFTCPSocket *)stream
target: (id)target
selector: (SEL)selector
context: (id)context
{
ADD_READ(OFRunLoop_AcceptQueueItem, stream, {
|
>
>
>
>
>
>
>
>
>
>
>
>
|
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
|
queueItem->_target = [target retain];
queueItem->_selector = selector;
queueItem->_context = [context retain];
queueItem->_buffer = buffer;
queueItem->_length = length;
})
}
+ (void)of_addAsyncConnectForTCPSocket: (OFTCPSocket *)stream
target: (id)target
selector: (SEL)selector
context: (id)context
{
ADD_WRITE(OFRunLoop_ConnectQueueItem, stream, {
queueItem->_target = [target retain];
queueItem->_selector = selector;
queueItem->_context = [context retain];
})
}
+ (void)of_addAsyncAcceptForTCPSocket: (OFTCPSocket *)stream
target: (id)target
selector: (SEL)selector
context: (id)context
{
ADD_READ(OFRunLoop_AcceptQueueItem, stream, {
|