From 6bed22094af018434cae331d695c7731f26d1408 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 10 Oct 2015 10:41:12 -0400 Subject: [PATCH] Remove unnecessary ivars from ProtocolClient. --- Source/ProtocolClient.h | 16 ++-------------- Source/ProtocolClient.m | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Source/ProtocolClient.h b/Source/ProtocolClient.h index 83bb7d1..698e90e 100644 --- a/Source/ProtocolClient.h +++ b/Source/ProtocolClient.h @@ -23,21 +23,9 @@ // ProtocolClient sends string commands to a DBGP // debugger engine and receives XML packets in response. This class ensures // proper sequencing of the messages. -@interface ProtocolClient : NSObject { - @private - MessageQueue* _messageQueue; +@interface ProtocolClient : NSObject - NSRecursiveLock* _lock; - NSInteger _nextID; - - NSInteger _lastReadID; - NSInteger _lastWrittenID; - - NSObject* _delegate; - NSThread* _delegateThread; -} - -- (id)initWithDelegate:(NSObject*)delegate; +- (id)initWithDelegate:(id)delegate; - (BOOL)isConnected; diff --git a/Source/ProtocolClient.m b/Source/ProtocolClient.m index 91da70f..a8e1610 100644 --- a/Source/ProtocolClient.m +++ b/Source/ProtocolClient.m @@ -19,19 +19,31 @@ #import "AppDelegate.h" #import "LoggingController.h" -@implementation ProtocolClient +@implementation ProtocolClient { + // The object responsible for the actual communication with the debug server. + MessageQueue* _messageQueue; -- (id)initWithDelegate:(NSObject*)delegate { + // The delegate of this class, which receives high-level messages about the + // state of the debugger. + id _delegate; // weak + + // The next transaction ID to assign. + NSInteger _nextID; + + // Records the last read and written transaction IDs. These are only used in + // creating LogEntry objects. + NSInteger _lastReadID; + NSInteger _lastWrittenID; +} + +- (id)initWithDelegate:(id)delegate { if ((self = [super init])) { _delegate = delegate; - _delegateThread = [NSThread currentThread]; - _lock = [[NSRecursiveLock alloc] init]; } return self; } - (void)dealloc { - [_lock release]; [super dealloc]; } @@ -117,11 +129,9 @@ } - (void)messageQueueDidConnect:(MessageQueue*)queue { - [_lock lock]; _nextID = 0; _lastReadID = 0; _lastWrittenID = 0; - [_lock unlock]; [_delegate debuggerEngineConnected:self]; } @@ -136,9 +146,7 @@ - (void)messageQueue:(MessageQueue*)queue didSendMessage:(NSString*)message { NSInteger tag = [self transactionIDFromCommand:message]; - [_lock lock]; _lastWrittenID = tag; - [_lock unlock]; LoggingController* logger = [[AppDelegate instance] loggingController]; LogEntry* entry = [LogEntry newSendEntry:message]; -- 2.22.5