-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMAAsyncWriter.h
More file actions
50 lines (36 loc) · 1.05 KB
/
MAAsyncWriter.h
File metadata and controls
50 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
//
// MAAsyncWriter.h
// MAAsyncIO
//
// Created by Michael Ash on 12/3/10.
// Copyright 2010 Michael Ash. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@class MAFDSource;
@interface MAAsyncWriter : NSObject
{
MAFDSource *_fdSource;
int _fd;
NSMutableData *_buffer;
void (^_errorHandler)(int);
void (^_didWriteCallback)(void);
void (^_eofCallback)(void);
BOOL _invalidateWhenEmptyBuffer;
}
// initialization
- (id)initWithFileDescriptor: (int)fd; // sets fd nonblocking, uses MAFDRetain/MAFDRelease to manage it
// setup
- (void)setErrorHandler: (void (^)(int err))block;
- (void)setTargetQueue: (dispatch_queue_t)queue; // default is normal global queue
// notification
- (void)setDidWriteCallback: (void (^)(void))block;
- (void)setEOFCallback: (void (^)(void))block;
// writing
- (void)writeData: (NSData *)data;
- (void)writeCString: (const char *)cstr;
// buffer inspection, can only be called from a callback
- (NSUInteger)bufferSize;
// stopping
- (void)invalidate;
- (void)invalidateWhenEmptyBuffer;
@end