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
|
|
|
|
//
|
2006-09-04 18:46:18 +00:00
|
|
|
// Created by Vincent Spader on 1/4/06.
|
|
|
|
// Copyright 2006 Vincent Spader. All rights reserved.
|
2006-01-20 15:34:02 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import "VirtualRingBuffer.h"
|
|
|
|
#import "Semaphore.h"
|
|
|
|
|
2007-03-04 16:00:26 +00:00
|
|
|
#define BUFFER_SIZE 1024 * 1024
|
2006-01-20 15:34:02 +00:00
|
|
|
#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
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
id __weak previousNode;
|
|
|
|
id __weak controller;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2007-10-03 20:23:14 +00:00
|
|
|
BOOL shouldReset;
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
BOOL shouldContinue;
|
2006-04-02 15:44:08 +00:00
|
|
|
BOOL endOfStream; //All data is now in buffer
|
2007-03-19 00:19:47 +00:00
|
|
|
BOOL initialBufferFilled;
|
2006-01-20 15:34:02 +00:00
|
|
|
}
|
2007-02-24 20:36:27 +00:00
|
|
|
- (id)initWithController:(id)c previous:(id)p;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
- (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;
|
|
|
|
|
2007-10-03 20:23:14 +00:00
|
|
|
- (void)setShouldReset:(BOOL)s;
|
|
|
|
- (BOOL)shouldReset;
|
|
|
|
|
2006-04-02 20:03:12 +00:00
|
|
|
- (NSLock *)readLock;
|
|
|
|
- (NSLock *)writeLock;
|
|
|
|
|
2008-02-16 02:46:19 +00:00
|
|
|
- (void)setPreviousNode:(id)p;
|
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;
|
|
|
|
|
2016-06-30 05:10:29 +00:00
|
|
|
//-(void)resetBuffer;
|
2007-10-03 20:23:14 +00:00
|
|
|
|
2006-04-02 15:44:08 +00:00
|
|
|
- (BOOL)endOfStream;
|
|
|
|
- (void)setEndOfStream:(BOOL)e;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
@end
|