5 ms·
Asynchronous message passing in Objective-C
- sp00nman 15y agoWhy must these sorts of contributions always be BSD licensed, what is wrong with public domain?
- cdcarter 15y agoThis stackoverflow page has some good comments on what it means to release into public domain: http://stackoverflow.com/questions/219742/open-source-why-not-release-into-public-domain http://stackoverflow.com/questions/219742/open-source-why-no.... The answer, in some cases, is nothing.
- masklinn 15y ago> The answer, in some cases, is nothing. And, in many cases, everything. SQLite users have had this issue in the past: http://www.sqlite.org/copyright.html http://www.sqlite.org/copyright.html
- nickcharlton 15y agoIt's also convention to license Apple-related projects as they do. Which are generally MIT/BSD variants.
- jensnockert 15y agoBecause Public Domain is complex, the BSD license is pretty clear and applicable in the whole world.
- aaronblohowiak 15y agoThe public domain doesn't exist in some places like it does in the US. SQLlite takes a different approach where it is all licensed under the public domain but you can buy a license for $1,000.00
- SeanLuke 15y agoThe US too. The public domain is where things go when their copyright expires. In most countries -- including the United States -- there is no legal procedure to dedicate something to the public domain. You can claim something you wrote is in the public domain until you're blue in the face, but it's not. You still own the copyright on it. The closest you can get to a public domain declaration is a bare license: basically a license which says "Copyright 2012 by me: I give you the license to do whatever you want with this." The problem with a bare license is that if your code doesn't work right, people can (and do) turn around and sue your pants off. Because -- remember -- the work is not in the public domain. You own it and are responsible for it. Thus we get to a BSD-style ("academic") license. At a minimum this license says "Copyright 2012 by me: I give you a license to do whatever you want with this as long as you agree not to sue me if something doesn't work". Always use, at a minimum, a BSD-style license. Public domain is a fiction.
- tptacek 15y agoThe stridency/accuracy ratio of this comment is interesting. http://cr.yp.to/publicdomain.html http://cr.yp.to/publicdomain.html
- dctoedt 15y agoThe GP [SeanLuke] does make one good point, which is that using a BSD-style license is a good idea, because it gives you ammunition to help defeat a "creative" claim that you should be liable for problems other people have with your code. Otherwise, I agree, there are a fair number of inaccuracies in the GP [SeanLuke] comment.
- tptacek 15y agoWhile conceding immediately that you generally do want to take whatever "free" steps that are available to you to avoid frivolous lawsuits, what's your take on how likely it is that someone would prevail with a claim like "a bug in the software code that you abandoned all claims to cost me millions of dollars"? (I ask because I'm curious, not to further a debate about PD).
- oofabz 15y agoI greatly prefer PLActorKit by Landon Fuller: http://code.google.com/p/plactorkit/ http://code.google.com/p/plactorkit/
- phil 15y agoThese days, why not use GCD and blocks for this kind of work?
- kennywinker 15y agoMy thoughts exactly. NSOperationQueue *queue = [NSOperationQueue mainQueue]; [queue addOperation:[NSBlockOperation blockOperationWithBlock:^{ // do something }]]; or NSOperationQueue *queue = [NSOperationQueue mainQueue]; [queue addOperation:[[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(selectorName:) object:param1] autorelease]]; Edit: on re-reading the post in detail, I see the problem he is solving is different from the one the above code solves. Clearly there is value to what he has made. I wonder if it could not be re-coded using gcd and/or blocks, but NSOperationQueue is too high-level an API to be appropriate. Still, I can't tell you how many times I've used the code above to create simple async systems.
- phil 15y agoHow is the problem he is solving different? I guess using an actor chain and messages allows you to repeatedly drop many messages through the same sequence of operations. While you might express that slightly differently if you used GCD or operation queues, you should be able to make it just as readable. Blocks are pretty cheap, so any performance hit should be more than offset by the gains you get from having the OS manage your thread pool for you.
- richcollins 15y agoAlso see ActorKit from the inventor of Io: https://github.com/stevedekorte/ActorKit https://github.com/stevedekorte/ActorKit
- dgallagher 15y agoThat's really cool. For the heck of it I increased the actor count to 16 and CPU-usage stayed ~50% when running (Core i7, dual core w/hyper-threading). If you comment out the NSLog call, it spikes to ~280% CPU usage, as the overhead introduced by NSLog is likely slowing things down.
- deleted 15y ago[deleted]
- SeanLuke 15y agoThis reminds me, for some reason even though it's totally different, of NeXT's Distributed Objects facility, which I think is still floating around OS X but am not sure. Here's how it worked. In Objective-C, method calls are dynamically bound. So you can make the following call: [myObject crazyMethodName:x:y:z] In Java that'd be myObject.crazyMethodName(x,y,z) However unlike Java, there doesn't have to be a method called crazyMethodName, and the compiler will still compile it just fine. What happens is that at runtime, when this method is called, the message "crazyMethodName" is sent to myObject. If it doesn't have a method which responds to that name, then Objective-C calls the "forward" message on myObject, passing in the "crazyMethodName" method name and the arguments. "forward" can do what it likes with this -- the default implementation of "forward" is (was?) to issue a No Such Method Found error. What Distributed Objects did was create a special proxy object which has a single method implemented: "forward". The system worked as follows. When machine A connects to machine B, machine B gives machine A its "entry" object (as defined by the user). B thinks it gave A an object, but in fact what A received was a proxy object. Let's say that the entry object responds to a method "foo". A calls [obj foo] obj is actually a proxy which responds to no methods at all, except for "forward". Objective-C fails to call "foo" on obj, so it tries "forward", and lo and behold the proxy has implemented that in a special way -- it wraps up the method call and ships it over to machine B and calls "foo" on the real object. Through this procedure objects get passed as arguments back and forth through these method calls, which in turn wind up generating more and more proxies. Ultimately neither machine knows that the objects it's got access to are fakes. It just feels like you've been given access to call and manipulate another processes objects. Very clean and elegant.
- zrail 15y agoI wonder if this inspired DRb[1]. It sounds very similar. The biggest problem is that it's synchronous even across machine boundaries. Celluloid and Dcell[2] are the same basic idea but more explicit. [1]: http://segment7.net/projects/ruby/drb/introduction.html http://segment7.net/projects/ruby/drb/introduction.html [2]: http://www.unlimitednovelty.com/2011/05/introducing-celluloid-concurrent-object.html http://www.unlimitednovelty.com/2011/05/introducing-celluloi...
- krevis 15y ago