Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleanup and renaming SyncProxy to ThreadSafeProxy

  • Loading branch information...
commit d569a2c5c6fa80ca0aa04eed7e6f418eee16cfa6 1 parent b11f3d7
@stevedekorte authored
View
16 ActorKit.xcodeproj/project.pbxproj
@@ -15,8 +15,8 @@
AA2FB4A9141F5EB700E57E01 /* NSObject+Actor.h in Headers */ = {isa = PBXBuildFile; fileRef = AA2FB4A7141F5EB700E57E01 /* NSObject+Actor.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA2FB4AA141F5EB700E57E01 /* NSObject+Actor.m in Sources */ = {isa = PBXBuildFile; fileRef = AA2FB4A8141F5EB700E57E01 /* NSObject+Actor.m */; };
AA2FB4AC141FF34200E57E01 /* README.txt in Resources */ = {isa = PBXBuildFile; fileRef = AA2FB4AB141FF34200E57E01 /* README.txt */; };
- AA300E071420649100A63289 /* SyncProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = AA300E051420649100A63289 /* SyncProxy.h */; settings = {ATTRIBUTES = (Public, ); }; };
- AA300E081420649100A63289 /* SyncProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = AA300E061420649100A63289 /* SyncProxy.m */; };
+ AA300E071420649100A63289 /* ThreadSafeProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = AA300E051420649100A63289 /* ThreadSafeProxy.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ AA300E081420649100A63289 /* ThreadSafeProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = AA300E061420649100A63289 /* ThreadSafeProxy.m */; };
AA38C81B142162020081CA9C /* NSArray+Actor.h in Headers */ = {isa = PBXBuildFile; fileRef = AA38C819142162020081CA9C /* NSArray+Actor.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA38C81C142162020081CA9C /* NSArray+Actor.m in Sources */ = {isa = PBXBuildFile; fileRef = AA38C81A142162020081CA9C /* NSArray+Actor.m */; };
AA38C820142163F60081CA9C /* BatchProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = AA38C81E142163F60081CA9C /* BatchProxy.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -41,8 +41,8 @@
AA2FB4A7141F5EB700E57E01 /* NSObject+Actor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+Actor.h"; sourceTree = "<group>"; };
AA2FB4A8141F5EB700E57E01 /* NSObject+Actor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+Actor.m"; sourceTree = "<group>"; };
AA2FB4AB141FF34200E57E01 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = SOURCE_ROOT; };
- AA300E051420649100A63289 /* SyncProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyncProxy.h; sourceTree = "<group>"; };
- AA300E061420649100A63289 /* SyncProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SyncProxy.m; sourceTree = "<group>"; };
+ AA300E051420649100A63289 /* ThreadSafeProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSafeProxy.h; sourceTree = "<group>"; };
+ AA300E061420649100A63289 /* ThreadSafeProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThreadSafeProxy.m; sourceTree = "<group>"; };
AA38C819142162020081CA9C /* NSArray+Actor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Actor.h"; sourceTree = "<group>"; };
AA38C81A142162020081CA9C /* NSArray+Actor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Actor.m"; sourceTree = "<group>"; };
AA38C81E142163F60081CA9C /* BatchProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BatchProxy.h; sourceTree = "<group>"; };
@@ -136,8 +136,8 @@
AA2FB4A8141F5EB700E57E01 /* NSObject+Actor.m */,
AA9A97861419785000A2994E /* NSThread+Actor.h */,
AA9A97871419785000A2994E /* NSThread+Actor.m */,
- AA300E051420649100A63289 /* SyncProxy.h */,
- AA300E061420649100A63289 /* SyncProxy.m */,
+ AA300E051420649100A63289 /* ThreadSafeProxy.h */,
+ AA300E061420649100A63289 /* ThreadSafeProxy.m */,
AABB5D9F140E0C220020BA06 /* Supporting Files */,
);
path = ActorKit;
@@ -168,7 +168,7 @@
AA2FB4A4141F533C00E57E01 /* FutureProxy.h in Headers */,
AA2FB4A9141F5EB700E57E01 /* NSObject+Actor.h in Headers */,
AA9A97881419785000A2994E /* NSThread+Actor.h in Headers */,
- AA300E071420649100A63289 /* SyncProxy.h in Headers */,
+ AA300E071420649100A63289 /* ThreadSafeProxy.h in Headers */,
AA38C81B142162020081CA9C /* NSArray+Actor.h in Headers */,
AA38C820142163F60081CA9C /* BatchProxy.h in Headers */,
AA38C824142178190081CA9C /* NSInvocation+Copy.h in Headers */,
@@ -241,7 +241,7 @@
AA2FB4A3141F533C00E57E01 /* ActorProxy.m in Sources */,
AA2FB4A5141F533C00E57E01 /* FutureProxy.m in Sources */,
AA2FB4AA141F5EB700E57E01 /* NSObject+Actor.m in Sources */,
- AA300E081420649100A63289 /* SyncProxy.m in Sources */,
+ AA300E081420649100A63289 /* ThreadSafeProxy.m in Sources */,
AA38C81C142162020081CA9C /* NSArray+Actor.m in Sources */,
AA38C821142163F60081CA9C /* BatchProxy.m in Sources */,
AA38C825142178190081CA9C /* NSInvocation+Copy.m in Sources */,
View
2  ActorKit/ActorKit.h
@@ -8,7 +8,7 @@
#import "ActorProxy.h"
#import "BatchProxy.h"
-#import "SyncProxy.h"
+#import "ThreadSafeProxy.h"
#import "NSObject+Actor.h"
#import "NSArray+Actor.h"
View
2  ActorKit/BatchProxy.m
@@ -42,7 +42,7 @@ - (dispatch_queue_t)batchDispatchQueue
- (void)forwardInvocation:(NSInvocation *)theInvocation
{
- __block anInvocation = theInvocation;
+ __block NSInvocation *anInvocation = theInvocation;
if([[anInvocation methodSignature] methodReturnType][0] != '@')
{
View
4 ActorKit/NSObject+Actor.h
@@ -7,7 +7,7 @@
//
#import "ActorProxy.h"
-#import "SyncProxy.h"
+#import "ThreadSafeProxy.h"
#import "BatchProxy.h"
@interface NSObject (NSObject_Actor)
@@ -15,6 +15,6 @@
- proxyForProxyClass:(Class)aClass;
- asActor;
-- asSynchronous;
+- asThreadSafe;
@end
View
14 ActorKit/NSObject+Actor.m
@@ -30,9 +30,9 @@ @implementation NSObject (NSObject_Actor)
return [self proxyForProxyClass:[ActorProxy class]];
}
-- asSynchronous
+- asThreadSafe
{
- return [self proxyForProxyClass:[SyncProxy class]];
+ return [self proxyForProxyClass:[ThreadSafeProxy class]];
}
/*
@@ -52,16 +52,16 @@ @implementation NSObject (NSObject_Actor)
return (id)actor;
}
-static char *synchoronousKey = "SyncProxy";
+static char *synchoronousKey = "ThreadSafeProxy";
-- asSynchronous
+- asThreadSafe
{
- SyncProxy *sp = objc_getAssociatedObject(self, synchoronousKey);
+ ThreadSafeProxy *sp = objc_getAssociatedObject(self, synchoronousKey);
if(!sp)
{
- sp = [[[SyncProxy alloc] init] autorelease];
- [sp setSyncProxyTarget:self];
+ sp = [[[ThreadSafeProxy alloc] init] autorelease];
+ [sp setThreadSafeProxyTarget:self];
objc_setAssociatedObject(self, synchoronousKey, sp, OBJC_ASSOCIATION_ASSIGN);
}
View
2  ActorKit/SyncProxy.h → ActorKit/ThreadSafeProxy.h
@@ -7,7 +7,7 @@
//
// A simple proxy wrapper that synchronizes all messages to the target
-@interface SyncProxy : NSProxy
+@interface ThreadSafeProxy : NSProxy
{
id syncProxyTarget;
NSLock *syncProxyLock;
View
12 ActorKit/SyncProxy.m → ActorKit/ThreadSafeProxy.m
@@ -6,30 +6,30 @@
// Copyright 2011 Steve Dekorte. BSD licensed.
//
-#import "SyncProxy.h"
+#import "ThreadSafeProxy.h"
-@implementation SyncProxy
+@implementation ThreadSafeProxy
@synthesize syncProxyTarget;
@synthesize syncProxyLock;
- init
{
- [self setSyncProxyLock:[[[NSLock alloc] init] autorelease]];
+ [self setThreadSafeProxyLock:[[[NSLock alloc] init] autorelease]];
return self;
}
- (void)dealloc
{
- [self setSyncProxyTarget:nil];
- [self setSyncProxyLock:nil];
+ [self setThreadSafeProxyTarget:nil];
+ [self setThreadSafeProxyLock:nil];
[super dealloc];
}
- (void)setProxyTarget:anObject
{
- [self setSyncProxyTarget:anObject];
+ [self setThreadSafeProxyTarget:anObject];
[syncProxyLock setName:[syncProxyTarget description]];
}
View
23 README.txt
@@ -26,25 +26,25 @@ FutureProxy
Example
- // these spawn threads for each actor to and return immediately
+ // the fetch return a future immediately
NSData *aFuture = [(NSURL *)[[@"http://yahoo.com" asURL] asActor] fetch];
- // ... do stuff that doesn't need to wait on the results ...
+ // ... do stuff ...
- // now when we try to access the values, they block if the values aren't ready
+ // now when we try to access the values, the thread waits if the values aren't ready
NSLog(@"request returned %i bytes", (int)[aFuture length]);
-SyncProxy
+ThreadSafeProxy
- Calling asSynchronous on any object returns a SyncProxy for it. Example:
+ Calling asThreadSafe on any object returns a proxy that ensures only one thread
+ can access it at a time. Example:
- NSMutableDictionary *dict = [[NSMutableDictionary dictionary] asSynchronous];
+ NSMutableDictionary *dict = [[NSMutableDictionary dictionary] asThreadSafe];
- You now have a thread safe dictionary.
@@ -54,6 +54,9 @@ BatchProxy
a parallel "map" using GCD (BSD workerqueues). Example:
NSArray *results = [[urls asBatch] fetch];
+
+ Sends concurrent fetch messages to each element of the urls array and returns
+ an array containing the results.
@@ -75,11 +78,11 @@ To Do
- handle BatchProxy exceptions
- - extend collection classes to use workqueues for makeObjectsPerform: etc
-
+ - make sure all locks deal with exceptions
+
- future notifications of some kind
- - tests
+ - more tests
- convenience methods for returning NSNumbers instead of C types
Please sign in to comment.
Something went wrong with that request. Please try again.