Asyncronous tasks in Murky

3 views
Skip to first unread message

Raphael Sebbe

unread,
Mar 11, 2011, 4:03:28 AM3/11/11
to murk...@googlegroups.com
Hi guys,

I've been experimenting a bit with async tasks in Murky these last few days, with a GCD/Block approach.

Basically, I first added an async -run method to MYTask:


- (void) runWithCompletionHandler:(void (^)(BOOL result, NSError *error))handler;


and then have some async equivalent to existing higher level methods:

- (void) _checkRevisionsCompletionHandler:(void(^)(BOOL result))handler

- (void)getCurrentRevisionCompletionHandler:(void(^)(HgRevision *rev))handler

- (void) _getRevNumbers: (NSString*)cmd completionHandler:(void(^)(NSArray *revs, NSError *error))handler

- (void) _getTipCompletionHandler:(void(^)(int))handler

...


There were some low level issues with NSTask, but I think I got it to work in the end. I also think that the problem some of you were having with NSTask not sending its completion notification is now solved as well. The cause was that the garbage collector was collecting some MYTask objects before the notification was sent, because the NSNotificationCenter only keeps zeroing weak reference to observers.

I then moved to a use case for this async feature, with background retrieval and display of incoming/outgoing revs to default remote in the project window. There are still some issues, but it's starting to work. There are plenty of places were async handling could be used instead of UI-blocking, synchronous calls, but I made it in a way that both can coexist. That makes it more comfortable to upgrade the whole app.

As there are quite a lot of changes, some probably breaking existing stuff, I'll have a fork for the project so that we can discuss the proposed changes without altering the main repository. Please let me know of your thoughts.

Screen shot 2011-03-11 at 09.51.44.png
--
Raphael Sebbe
Creaceed — Creative iPhone & Mac apps
••• Twitter: http://twitter.com/rsebbe
••• Web: http://www.creaceed.com
Screen shot 2011-03-11 at 09.51.44.png

Raphael Sebbe

unread,
Mar 12, 2011, 1:00:13 PM3/12/11
to murk...@googlegroups.com
Hi,

I just put the the asynchronous stuff into my fork of Murky. Feel free to comment on it.

Quick notes:
• UI for incoming/outgoing counts is not very nice.
• It will update the counts every 5 min. This should be made into a pref I think.
• I made it so that no more than 15 async NSTasks are running at the same time. It would go up to 30 in my setup, which was slowing down (a bit) the MacBook. On Mac Pro, it was just OK. We could have a value depending on the machine, or even a user pref with that.
• I've made some changes related to Xcode4. I couldn't get the Localize scripts to work, so I temporarily disabled them.
• As a side note, haven't you considered using Localization Suite for managing languages? I use it in my apps, external translators, etc., works very well.
• I added an NSPipe for NSTasks input. This is to get debug log that was otherwise not getting to the console
• Not closely related, but I was wondering if attacking directly the Python API wouldn't better (VM loading, memory consumption, etc.), instead of running NSTasks. What do you think? This would be a big change of course

Regards,

Raphael

-- 
Raphael Sebbe
Creaceed — Creative iPhone & Mac apps
••• Twitter: http://twitter.com/rsebbe
Reply all
Reply to author
Forward
0 new messages