nemequ / sqlheavy

Automatically exported from code.google.com/p/sqlheavy
Other
5 stars 4 forks source link

Cancelling async operation doesn't cancel background thread #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We've noticed here that when an async operation is canceled via its 
Cancellable, the thread for the operation is still being created.  This is most 
apparent when running the app under gdb, which logs to the console each thread 
creation and destruction.

Without too much investigation, I believe the problem is in 
QueryResult.next_internal_async(), where the "cancel" signal handler checks to 
see if the thread has started executing.  If not, it calls thread.exit(null).

The problem is, Thread.exit() is a static method that kills the currently 
executing thread.  (I believe this is having no effect because it recognizes 
it's being called from the main thread.)  It's a bug in the Vala compiler that 
allows for a static method to be called from an instance variable:

https://bugzilla.gnome.org/show_bug.cgi?id=661034

As far as I can tell, there's no way in GLib to kill a thread once it's been 
scheduled.

If #11 is implemented where threads are recycled, this problem goes away.

Original issue reported on code.google.com by j...@yorba.org on 5 Oct 2011 at 11:39

GoogleCodeExporter commented 9 years ago
Incidentally, the Vala bug I registered is not considered a bug (and, in fact, 
is legal in Java and other Java-ish languages), so that's not going away.

Original comment by j...@yorba.org on 12 Oct 2011 at 12:02