Closed tkf closed 12 years ago
Right, I definitely plan to move to an asynchronous system once I've got a good grasp on the basics. I don't know when that'll be, but it'll be a necessity for larger projects.
Austin
On Mon, Jul 23, 2012 at 7:42 PM, Takafumi Arakaki reply@reply.github.com wrote:
Isn't it better to use
xml-rpc-method-call-async
instead ofxml-rpc-method-call
? Asynchronous programming is bit hard but otherwise you can't use the advantage of having multiple processes. I prefer not waiting during traad does the job in background.
Reply to this email directly or view it on GitHub: https://github.com/abingham/traad/issues/6
Cool! I can't wait to see that. I'm closing this as it's on your plan.
I've added some support for async calls. The refactorings should all run asynchronously now, so let me know what you think.
One issue related to this which I haven't resolved yet is how to properly revert buffers associated with refactorings. Prior to this change, the buffer from which a refactoring was run would be automatically reverted when the refactoring finished. I'm not sure what the best way to do that is with the async call handler...any thoughts or advice?
Awesome! I haven't tried yet, but by quick glance, I think changing traad-call-async
to something like
(defun traad-call-async (callback func &rest args)
(apply
#'xml-rpc-method-call-async
(lexical-let ((callback callback))
(lambda (result) (traad-async-handler result callback)))
(concat
"http://" traad-host ":"
(number-to-string traad-port))
func args))
should solve the problem. You can revert buffer in the callback. Probably you would want to add another argument for callback so that you can call it like this (traad-call-async func funargs callback cbargs)
, otherwise, user of traad-call-async must use lexical-let
again.
Great, thanks. I've implemented part of what you suggested, and I'll look at the rest (the cbargs bit) when I get a chance.
Isn't it better to use
xml-rpc-method-call-async
instead ofxml-rpc-method-call
? Asynchronous programming is bit hard but otherwise you can't use the advantage of having multiple processes. I prefer not waiting during traad does the job in background.