Add:core: event_call_callback infrastructure|
authorzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 7 Nov 2008 12:29:44 +0000 (12:29 +0000)
committerzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 7 Nov 2008 12:29:44 +0000 (12:29 +0000)
To be used from threads that want to call the callback
from the main(gui) thread. Users must provide
synhronization of the callback data.
Difference with using timeouts are:
Threads can have own timers
Timer events are low priority, this must be called ASAP.

git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1674 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/event.c
navit/event.h
navit/event_glib.c
navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
navit/graphics/win32/graphics_win32.c

index 87e1798..42929d5 100644 (file)
@@ -78,6 +78,12 @@ event_remove_idle(struct event_idle *ev)
        event_methods.remove_idle(ev);
 }
 
+void
+event_call_callback(struct callback *cb)
+{
+       event_methods.call_callback(cb);
+}
+
 int
 event_request_system(char *system, char *requestor)
 {
index 0f02278..fb0c37d 100644 (file)
@@ -42,6 +42,7 @@ struct event_methods {
        void (*remove_timeout)(struct event_timeout *ev);
        struct event_idle *(*add_idle)(struct callback *cb);
        void (*remove_idle)(struct event_idle *ev);
+       void (*call_callback)(struct callback *cb);
 };
 
 
@@ -55,6 +56,7 @@ void event_remove_timeout(struct event_timeout *ev);
 struct event_idle *event_add_idle(struct callback *cb);
 void event_remove_idle(struct event_idle *ev);
 int event_request_system(char *system, char *requestor);
+void event_call_callback(struct callback *cb);
 /* end of prototypes */
 #ifdef __cplusplus
 }
index 730d908..7fc0bbb 100644 (file)
@@ -136,6 +136,18 @@ event_glib_remove_idle(struct event_idle *ev)
 {
 }
 
+static void
+event_glib_call_callback(struct callback *cb)
+{
+/* 
+ Idea for implementation:
+ Create a pipe then use add_watch
+ add callback to a queue
+ from here write to the pipe to wakeup the pool
+ then from the gui thread process the callback queue
+*/
+}
+
 static struct event_methods event_glib_methods = {
        event_glib_main_loop_run,
        event_glib_main_loop_quit,
@@ -145,6 +157,7 @@ static struct event_methods event_glib_methods = {
        event_glib_remove_timeout,
        event_glib_add_idle,
        event_glib_remove_idle,
+       event_glib_call_callback,
 };
 
 static void
index fc4d506..374279f 100644 (file)
@@ -759,6 +759,12 @@ event_qt_remove_idle(struct event_idle *ev)
        dbg(0,"enter\n");
 }
 
+static void
+event_qt_call_callback(struct callback *cb)
+{
+       dbg(0,"enter\n");
+}
+
 static struct event_methods event_qt_methods = {
        event_qt_main_loop_run,
        event_qt_main_loop_quit,
@@ -768,6 +774,7 @@ static struct event_methods event_qt_methods = {
        event_qt_remove_timeout,
        event_qt_add_idle,
        event_qt_remove_idle,
+       event_qt_call_callback,
 };
 
 struct event_priv {
index 063b3ef..7295809 100644 (file)
@@ -923,6 +923,12 @@ event_win32_remove_idle(struct event_idle *ev)
        dbg(0,"enter\n");
 }
 
+static void
+event_win32_call_callback(struct callback *cb)
+{
+       dbg(0,"enter\n");
+}
+
 static struct event_methods event_win32_methods = {
        event_win32_main_loop_run,
        event_win32_main_loop_quit,
@@ -932,6 +938,7 @@ static struct event_methods event_win32_methods = {
        event_win32_remove_timeout,
        event_win32_add_idle,
        event_win32_remove_idle,
+       event_win32_call_callback,
 };
 
 static struct event_priv *