mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Tidy up async operations
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13958 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
86c8f508ae
commit
84b32745c1
4 changed files with 95 additions and 38 deletions
|
@ -198,42 +198,62 @@ static Class NSFileHandle_ssl_class = nil;
|
|||
|
||||
// Asynchronous I/O operations
|
||||
|
||||
- (void) acceptConnectionInBackgroundAndNotify
|
||||
{
|
||||
[self acceptConnectionInBackgroundAndNotifyForModes: nil];
|
||||
}
|
||||
|
||||
- (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) acceptConnectionInBackgroundAndNotify
|
||||
/**
|
||||
* Call -readInBackgroundAndNotifyForModes: with nil modes.
|
||||
*/
|
||||
- (void) readInBackgroundAndNotify
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
[self readInBackgroundAndNotifyForModes: nil];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up an asynchonous read operation which will cause a notification to
|
||||
* be sent when any amount of data (or end of file) is read.
|
||||
*/
|
||||
- (void) readInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) readInBackgroundAndNotify
|
||||
/**
|
||||
* Call -readToEndOfFileInBackgroundAndNotifyForModes: with nil modes.
|
||||
*/
|
||||
- (void) readToEndOfFileInBackgroundAndNotify
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
[self readToEndOfFileInBackgroundAndNotifyForModes: nil];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up an asynchonous read operation which will cause a notification to
|
||||
* be sent when end of file is read.
|
||||
*/
|
||||
- (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) readToEndOfFileInBackgroundAndNotify
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
/**
|
||||
* Call -waitForDataInBackgroundAndNotifyForModes: with nil modes.
|
||||
*/
|
||||
- (void) waitForDataInBackgroundAndNotify
|
||||
{
|
||||
[self waitForDataInBackgroundAndNotifyForModes: nil];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up to provide a notification when data can be read from the handle.
|
||||
*/
|
||||
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
@ -404,6 +424,24 @@ NSString * const NSFileHandleOperationException
|
|||
protocol: protocol]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call -readDataInBackgroundAndNotifyLength:forModes: with nil modes.
|
||||
*/
|
||||
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len
|
||||
{
|
||||
[self readDataInBackgroundAndNotifyLength: len forModes: nil];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up an asynchonous read operation which will cause a notification to
|
||||
* be sent when the specified amount of data (or end of file) is read.
|
||||
*/
|
||||
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len
|
||||
forModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (BOOL) readInProgress
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
@ -430,12 +468,18 @@ NSString * const NSFileHandleOperationException
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes
|
||||
/**
|
||||
* Call -writeInBackgroundAndNotify:forModes: with nil modes.
|
||||
*/
|
||||
- (void) writeInBackgroundAndNotify: (NSData*)item
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
[self writeInBackgroundAndNotify: item forModes: nil];
|
||||
}
|
||||
|
||||
- (void) writeInBackgroundAndNotify: (NSData*)item
|
||||
/**
|
||||
* Write the specified data asynchronously, and notify on completion.
|
||||
*/
|
||||
- (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
|
|
@ -1384,9 +1384,26 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
[self watchReadDescriptorForModes: modes];
|
||||
}
|
||||
|
||||
- (void) acceptConnectionInBackgroundAndNotify
|
||||
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len
|
||||
forModes: (NSArray*)modes
|
||||
{
|
||||
[self acceptConnectionInBackgroundAndNotifyForModes: nil];
|
||||
NSMutableData *d;
|
||||
|
||||
[self checkRead];
|
||||
if (len > 0x7fffffff)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"length (%u) too large", len];
|
||||
}
|
||||
readMax = len;
|
||||
RELEASE(readInfo);
|
||||
readInfo = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
||||
[readInfo setObject: NSFileHandleReadCompletionNotification
|
||||
forKey: NotificationKey];
|
||||
d = [[NSMutableData alloc] initWithCapacity: readMax];
|
||||
[readInfo setObject: d forKey: NSFileHandleNotificationDataItem];
|
||||
RELEASE(d);
|
||||
[self watchReadDescriptorForModes: modes];
|
||||
}
|
||||
|
||||
- (void) readInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
|
@ -1405,11 +1422,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
[self watchReadDescriptorForModes: modes];
|
||||
}
|
||||
|
||||
- (void) readInBackgroundAndNotify
|
||||
{
|
||||
return [self readInBackgroundAndNotifyForModes: nil];
|
||||
}
|
||||
|
||||
- (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
{
|
||||
NSMutableData *d;
|
||||
|
@ -1426,11 +1438,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
[self watchReadDescriptorForModes: modes];
|
||||
}
|
||||
|
||||
- (void) readToEndOfFileInBackgroundAndNotify
|
||||
{
|
||||
return [self readToEndOfFileInBackgroundAndNotifyForModes: nil];
|
||||
}
|
||||
|
||||
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes
|
||||
{
|
||||
[self checkRead];
|
||||
|
@ -1444,11 +1451,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
[self watchReadDescriptorForModes: modes];
|
||||
}
|
||||
|
||||
- (void) waitForDataInBackgroundAndNotify
|
||||
{
|
||||
return [self waitForDataInBackgroundAndNotifyForModes: nil];
|
||||
}
|
||||
|
||||
// Seeking within a file
|
||||
|
||||
- (unsigned long long) offsetInFile
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue