Thanks for the response, Nick.
The Lua code runs, but Geany becomes non-responsive while the spawned task is executing. Once the task finishes, control is given back to the IDE.
I guess what I'm ultimately trying to do is invoke the command as a background process allowing the user to continue using Geany, and then provide a dialog to alert the user once the task has completed.
-Tim
On 12 February 2010 05:20, Timothy Boronczyk tboronczyk@gmail.com wrote:
Thanks for the response, Nick.
The Lua code runs, but Geany becomes non-responsive while the spawned task is executing. Once the task finishes, control is given back to the IDE.
I guess what I'm ultimately trying to do is invoke the command as a background process allowing the user to continue using Geany, and then provide a dialog to alert the user once the task has completed.
Thats not what co-routines do, resume doesn't return until the co-routine exits or yields. Co-routines are not for running separate threads, they are for exiting and resuming functions from any nested location.
Cheers Lex
-Tim _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
I guess I misunderstood coroutines then. Apparently Lua only has "asymmetric coroutines" typically usable as generators? I did see http://www.lua.org/pil/9.4.html which talks about emulating multi-threading by managing several coroutines which always yield, though I suspect the dispatcher's execution would still block Geany with that approach. Either way, thanks Jeff and Lex.
While not the most elegant solution, I'll script a wrapper around the commands which will be responsible for alerting the user once the task has completed. Then I'll invoke the wrapper from the plug-in with geany.launch( ).
-Tim
On Thu, 11 Feb 2010 21:04:18 -0500, Timothy wrote:
Hey,
I guess I misunderstood coroutines then. Apparently Lua only has "asymmetric coroutines" typically usable as generators? I did see http://www.lua.org/pil/9.4.html which talks about emulating multi-threading by managing several coroutines which always yield, though I suspect the dispatcher's execution would still block Geany with that approach. Either way, thanks Jeff and Lex.
While not the most elegant solution, I'll script a wrapper around the commands which will be responsible for alerting the user once the task has completed. Then I'll invoke the wrapper from the plug-in with geany.launch( ).
I don't know at all but Geany provides utils_spawn_async() which executes a command asynchronous, i.e. Geany won't block during execution. Not sure whether it's available in the geanylua plugin but in case not, it probably could be added.
Regards, Enrico
Enrico, I looked at the source briefly and it looks like geany.launch() essentially wraps utils_spawn_async(), though it looks like it's only designed to execute a command-- not a Lua function asynchronously. It's fine, though. Here's how I worked around it:
#! /usr/bin/env lua
-- main execution begins here (function () -- was called by the user as a Geany plugin if (arg == nil) then -- determine arguments to send according to user selection geany.launch(geany.script, argument1, argument2, ... end
-- was called by the plugin as a shell script else -- construct cmd from incoming args cmd = ...
oc.execute(cmd) os.execute([[zenity --display=:0.0 --info --text="Action complete."]]) end)()
-Tim
I don't know at all but Geany provides utils_spawn_async() which executes a command asynchronous, i.e. Geany won't block during execution. Not sure whether it's available in the geanylua plugin but in case not, it probably could be added.
Regards, Enrico