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:
CaS 2002-06-23 19:53:15 +00:00
parent 86c8f508ae
commit 84b32745c1
4 changed files with 95 additions and 38 deletions

View file

@ -1,3 +1,11 @@
2002-06-23 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSFileHandle.h: add async read of specific length.
* Source/NSFileHandle.m: Make the async wconvenience methods call
the core ones.
* Source/UnixFileHandle.m: Remove async convenience methods and add
one to read specified length of data.
2002-06-21 Richard Frith-Macdonald <rfm@gnu.org> 2002-06-21 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSMime.m: add a few consistency checks to raise an exception * Source/GSMime.m: add a few consistency checks to raise an exception

View file

@ -62,14 +62,14 @@
// Asynchronous I/O operations // Asynchronous I/O operations
- (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes;
- (void) acceptConnectionInBackgroundAndNotify; - (void) acceptConnectionInBackgroundAndNotify;
- (void) readInBackgroundAndNotifyForModes: (NSArray*)modes; - (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes;
- (void) readInBackgroundAndNotify; - (void) readInBackgroundAndNotify;
- (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes; - (void) readInBackgroundAndNotifyForModes: (NSArray*)modes;
- (void) readToEndOfFileInBackgroundAndNotify; - (void) readToEndOfFileInBackgroundAndNotify;
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes; - (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes;
- (void) waitForDataInBackgroundAndNotify; - (void) waitForDataInBackgroundAndNotify;
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes;
// Seeking within a file // Seeking within a file
@ -132,6 +132,9 @@ GS_EXPORT NSString * const NSFileHandleOperationException;
service: (NSString*)service service: (NSString*)service
protocol: (NSString*)protocol protocol: (NSString*)protocol
forModes: (NSArray*)modes; forModes: (NSArray*)modes;
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len;
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len
forModes: (NSArray*)modes;
- (BOOL) readInProgress; - (BOOL) readInProgress;
- (NSString*) socketAddress; - (NSString*) socketAddress;
- (NSString*) socketService; - (NSString*) socketService;

View file

@ -198,42 +198,62 @@ static Class NSFileHandle_ssl_class = nil;
// Asynchronous I/O operations // Asynchronous I/O operations
- (void) acceptConnectionInBackgroundAndNotify
{
[self acceptConnectionInBackgroundAndNotifyForModes: nil];
}
- (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes - (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes
{ {
[self subclassResponsibility: _cmd]; [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 - (void) readInBackgroundAndNotifyForModes: (NSArray*)modes
{ {
[self subclassResponsibility: _cmd]; [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 - (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
- (void) readToEndOfFileInBackgroundAndNotify /**
{ * Call -waitForDataInBackgroundAndNotifyForModes: with nil modes.
[self subclassResponsibility: _cmd]; */
}
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes
{
[self subclassResponsibility: _cmd];
}
- (void) waitForDataInBackgroundAndNotify - (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]; [self subclassResponsibility: _cmd];
} }
@ -404,6 +424,24 @@ NSString * const NSFileHandleOperationException
protocol: protocol]); 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 - (BOOL) readInProgress
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
@ -430,12 +468,18 @@ NSString * const NSFileHandleOperationException
return NO; 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]; [self subclassResponsibility: _cmd];
} }

View file

@ -1384,9 +1384,26 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
[self watchReadDescriptorForModes: modes]; [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 - (void) readInBackgroundAndNotifyForModes: (NSArray*)modes
@ -1405,11 +1422,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
[self watchReadDescriptorForModes: modes]; [self watchReadDescriptorForModes: modes];
} }
- (void) readInBackgroundAndNotify
{
return [self readInBackgroundAndNotifyForModes: nil];
}
- (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes - (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes
{ {
NSMutableData *d; NSMutableData *d;
@ -1426,11 +1438,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
[self watchReadDescriptorForModes: modes]; [self watchReadDescriptorForModes: modes];
} }
- (void) readToEndOfFileInBackgroundAndNotify
{
return [self readToEndOfFileInBackgroundAndNotifyForModes: nil];
}
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes - (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes
{ {
[self checkRead]; [self checkRead];
@ -1444,11 +1451,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
[self watchReadDescriptorForModes: modes]; [self watchReadDescriptorForModes: modes];
} }
- (void) waitForDataInBackgroundAndNotify
{
return [self waitForDataInBackgroundAndNotifyForModes: nil];
}
// Seeking within a file // Seeking within a file
- (unsigned long long) offsetInFile - (unsigned long long) offsetInFile