@@ -16,25 +16,18 @@ #define __NO_EXT_QNX #include "config.h" -#include - #import "OFKernelEventObserver.h" #import "OFKernelEventObserver+Private.h" #import "OFArray.h" -#import "OFDictionary.h" #import "OFStream.h" #import "OFStream+Private.h" -#import "OFDataArray.h" #ifndef OF_HAVE_PIPE # import "OFStreamSocket.h" #endif -#ifdef OF_HAVE_THREADS -# import "OFMutex.h" -#endif #import "OFDate.h" #ifdef HAVE_KQUEUE # import "OFKernelEventObserver_kqueue.h" #endif @@ -53,18 +46,10 @@ #import "OFOutOfRangeException.h" #import "socket.h" #import "socket_helpers.h" -enum { - QUEUE_ADD = 0, - QUEUE_REMOVE = 1, - QUEUE_READ = 0, - QUEUE_WRITE = 2 -}; -#define QUEUE_ACTION (QUEUE_ADD | QUEUE_REMOVE) - @implementation OFKernelEventObserver @synthesize delegate = _delegate; + (void)initialize { @@ -108,13 +93,10 @@ socklen_t cancelAddrLen; #endif _readObjects = [[OFMutableArray alloc] init]; _writeObjects = [[OFMutableArray alloc] init]; - _queue = [[OFMutableArray alloc] init]; - _queueActions = [[OFDataArray alloc] - initWithItemSize: sizeof(int)]; #ifdef OF_HAVE_PIPE if (pipe(_cancelFD)) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; @@ -146,14 +128,10 @@ &cancelAddrLen) != 0) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; # endif #endif - -#ifdef OF_HAVE_THREADS - _mutex = [[OFMutex alloc] init]; -#endif } @catch (id e) { [self release]; @throw e; } @@ -170,168 +148,32 @@ of_socket_port_free(_cancelAddr.sin_port, SOCK_DGRAM); #endif [_readObjects release]; [_writeObjects release]; - [_queue release]; - [_queueActions release]; -#ifdef OF_HAVE_THREADS - [_mutex release]; -#endif [super dealloc]; } - (void)addObjectForReading: (id )object { -#ifdef OF_HAVE_THREADS - [_mutex lock]; -#endif - @try { - int qi = QUEUE_ADD | QUEUE_READ; - - [_queue addObject: object]; - [_queueActions addItem: &qi]; - } @finally { -#ifdef OF_HAVE_THREADS - [_mutex unlock]; -#endif - } - - [self cancel]; + OF_UNRECOGNIZED_SELECTOR } - (void)addObjectForWriting: (id )object { -#ifdef OF_HAVE_THREADS - [_mutex lock]; -#endif - @try { - int qi = QUEUE_ADD | QUEUE_WRITE; - - [_queue addObject: object]; - [_queueActions addItem: &qi]; - } @finally { -#ifdef OF_HAVE_THREADS - [_mutex unlock]; -#endif - } - - [self cancel]; + OF_UNRECOGNIZED_SELECTOR } - (void)removeObjectForReading: (id )object { -#ifdef OF_HAVE_THREADS - [_mutex lock]; -#endif - @try { - int qi = QUEUE_REMOVE | QUEUE_READ; - - [_queue addObject: object]; - [_queueActions addItem: &qi]; - } @finally { -#ifdef OF_HAVE_THREADS - [_mutex unlock]; -#endif - } - - [self cancel]; + OF_UNRECOGNIZED_SELECTOR } - (void)removeObjectForWriting: (id )object { -#ifdef OF_HAVE_THREADS - [_mutex lock]; -#endif - @try { - int qi = QUEUE_REMOVE | QUEUE_WRITE; - - [_queue addObject: object]; - [_queueActions addItem: &qi]; - } @finally { -#ifdef OF_HAVE_THREADS - [_mutex unlock]; -#endif - } - - [self cancel]; -} - -- (void)OF_addObjectForReading: (id)object -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)OF_addObjectForWriting: (id)object -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)OF_removeObjectForReading: (id)object -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)OF_removeObjectForWriting: (id)object -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)OF_processQueueAndStoreRemovedIn: (OFMutableArray*)removed -{ -#ifdef OF_HAVE_THREADS - [_mutex lock]; -#endif - @try { - id const *queueObjects = [_queue objects]; - int *queueActionItems = [_queueActions items]; - size_t i, count = [_queue count]; - - for (i = 0; i < count; i++) { - id object = queueObjects[i]; - int action = queueActionItems[i]; - - switch (action) { - case QUEUE_ADD | QUEUE_READ: - [_readObjects addObject: object]; - - [self OF_addObjectForReading: object]; - - break; - case QUEUE_ADD | QUEUE_WRITE: - [_writeObjects addObject: object]; - - [self OF_addObjectForWriting: object]; - - break; - case QUEUE_REMOVE | QUEUE_READ: - [self OF_removeObjectForReading: object]; - - [removed addObject: object]; - [_readObjects removeObjectIdenticalTo: object]; - - break; - case QUEUE_REMOVE | QUEUE_WRITE: - [self OF_removeObjectForWriting: object]; - - [removed addObject: object]; - [_writeObjects removeObjectIdenticalTo: object]; - - break; - default: - assert(0); - } - } - - [_queue removeAllObjects]; - [_queueActions removeAllItems]; - } @finally { -#ifdef OF_HAVE_THREADS - [_mutex unlock]; -#endif - } + OF_UNRECOGNIZED_SELECTOR } - (void)observe { [self observeForTimeInterval: -1];