2006-01-20 15:34:02 +00:00
|
|
|
//
|
2006-04-02 15:44:08 +00:00
|
|
|
// Node.h
|
2006-01-20 15:34:02 +00:00
|
|
|
// CogNew
|
|
|
|
//
|
|
|
|
// Created by Zaphod Beeblebrox on 1/4/06.
|
|
|
|
// Copyright 2006 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import "VirtualRingBuffer.h"
|
|
|
|
#import "Semaphore.h"
|
|
|
|
|
|
|
|
#define BUFFER_SIZE 512 * 1024
|
|
|
|
#define CHUNK_SIZE 16 * 1024
|
|
|
|
|
|
|
|
@interface Node : NSObject {
|
|
|
|
VirtualRingBuffer *buffer;
|
|
|
|
Semaphore *semaphore;
|
2006-04-02 20:03:12 +00:00
|
|
|
NSLock *readLock;
|
|
|
|
NSLock *writeLock;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
id previousNode;
|
|
|
|
id controller;
|
|
|
|
|
|
|
|
BOOL shouldContinue;
|
2006-04-02 15:44:08 +00:00
|
|
|
BOOL endOfStream; //All data is now in buffer
|
2006-01-20 15:34:02 +00:00
|
|
|
}
|
|
|
|
- (id)initWithPrevious:(id)p;
|
|
|
|
|
|
|
|
- (int)writeData:(void *)ptr amount:(int)a;
|
|
|
|
- (int)readData:(void *)ptr amount:(int)a;
|
|
|
|
|
|
|
|
- (void)process; //Should be overwriten by subclass
|
|
|
|
- (void)threadEntry:(id)arg;
|
|
|
|
|
|
|
|
- (void)launchThread;
|
|
|
|
|
2006-04-02 20:03:12 +00:00
|
|
|
- (NSLock *)readLock;
|
|
|
|
- (NSLock *)writeLock;
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
- (id)previousNode;
|
|
|
|
|
|
|
|
- (BOOL)shouldContinue;
|
|
|
|
- (void)setShouldContinue:(BOOL)s;
|
|
|
|
|
|
|
|
- (VirtualRingBuffer *)buffer;
|
2006-04-02 20:03:12 +00:00
|
|
|
- (void)resetBuffer; //WARNING! DANGER WILL ROBINSON!
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
- (Semaphore *)semaphore;
|
|
|
|
|
2006-04-02 15:44:08 +00:00
|
|
|
- (BOOL)endOfStream;
|
|
|
|
- (void)setEndOfStream:(BOOL)e;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
@end
|