java-gobject-introspection r76 - trunk/src/org/gnome/gir/gobject
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection r76 - trunk/src/org/gnome/gir/gobject
- Date: Thu, 9 Oct 2008 04:13:59 +0000 (UTC)
Author: walters
Date: Thu Oct 9 04:13:59 2008
New Revision: 76
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=76&view=rev
Log:
Add invokeLater (g_timeout_add)
Modified:
trunk/src/org/gnome/gir/gobject/MainLoop.java
Modified: trunk/src/org/gnome/gir/gobject/MainLoop.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/MainLoop.java (original)
+++ trunk/src/org/gnome/gir/gobject/MainLoop.java Thu Oct 9 04:13:59 2008
@@ -53,8 +53,11 @@
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import org.gnome.gir.gobject.GlibAPI.GSourceFunc;
+
import com.sun.jna.Pointer;
/**
@@ -214,6 +217,26 @@
}
}
+ public void invokeLater(int timeout, TimeUnit units, final Runnable r) {
+ GSourceFunc func = new GSourceFunc() {
+ @Override
+ public boolean callback(Pointer data) {
+ try {
+ r.run();
+ } catch (Exception e) {
+ Thread.currentThread().getUncaughtExceptionHandler()
+ .uncaughtException(Thread.currentThread(), e);
+ }
+ return false;
+ }
+ };
+ if (units.equals(TimeUnit.SECONDS)) {
+ GlibAPI.glib.g_timeout_add_seconds(timeout, func, null);
+ } else {
+ GlibAPI.glib.g_timeout_add((int) units.toMillis(timeout), func, null);
+ }
+ }
+
/**
* Stub interface for { code queue}.
* @author walters
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]