Run a callback by GTask from an extension

Hi everybody,

I run into an issue while developing an extension for Gnome Shell.
Long running _javascript_ code can make the whole Gnome Shell unresponsive for a second. Since I cannot reduce the execution time of the long running code, I want to move it out of the main loop's thread to a new one to make the UI update independent. I found that the best way would be to create a GTask to run my synchronous JS code asynchronously.

So I tried something like this:

let task =
    Lang.bind(this, function(){ /* do the heavy work */ }),
    Lang.bind(this, function(){ /* handle the result when ready */ }),

But that does not work, because the first argument is not a GObject, but a JS function.

I think that a passing a GClosure instead could work. Here is how I tries to instantiate it:

let closure = new{}, new;

Unfortunately this does not work either, probably the first argument has to be a GCallback.

Can I get some assistance?

Thanks in advance.


Búza Géza

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]