mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +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
753b52ef43
commit
f1aa57c3ed
4 changed files with 95 additions and 38 deletions
|
@ -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>
|
||||
|
||||
* Source/GSMime.m: add a few consistency checks to raise an exception
|
||||
|
|
|
@ -62,14 +62,14 @@
|
|||
|
||||
// Asynchronous I/O operations
|
||||
|
||||
- (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
- (void) acceptConnectionInBackgroundAndNotify;
|
||||
- (void) readInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
- (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
- (void) readInBackgroundAndNotify;
|
||||
- (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
- (void) readInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
- (void) readToEndOfFileInBackgroundAndNotify;
|
||||
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
- (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
- (void) waitForDataInBackgroundAndNotify;
|
||||
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes;
|
||||
|
||||
// Seeking within a file
|
||||
|
||||
|
@ -132,6 +132,9 @@ GS_EXPORT NSString * const NSFileHandleOperationException;
|
|||
service: (NSString*)service
|
||||
protocol: (NSString*)protocol
|
||||
forModes: (NSArray*)modes;
|
||||
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len;
|
||||
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len
|
||||
forModes: (NSArray*)modes;
|
||||
- (BOOL) readInProgress;
|
||||
- (NSString*) socketAddress;
|
||||
- (NSString*) socketService;
|
||||
|
|
|
@ -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…
Reference in a new issue