diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2007-03-06 17:15:03 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2007-03-06 17:15:03 +0000 |
| commit | 11a15d83a2be539c0e660c20ab92d8d4d2736f99 (patch) | |
| tree | 72283c2251a13b51143774d34d48efc79c67f5fc /FL | |
| parent | 6df72e8979a4276f799b4237c0b1f66b695b9b1b (diff) | |
This is a suggested change. It is complete except for documentation.
I did not like the awake_cb system at all. These changes implement Fl::awake(Fl_Awake_Handler, void*) which is called from a thread and tells the main loop to call the specified handler (rather a callback I guess) as soon as possible from within the main thread. It is implemented as Fifo (currently 1024 entry ring buffer), so handlers are called in the order that they are generated in.
"test/threads" was modified to change the label color as soon as a thread reaches 10000 - pretty boring, but it show the wonderful simplicity of this approach: you can write libraries that don't need to add to the main loop or register a handler at all... .
I will do some more stress testing tonight.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5729 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl.H | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -46,6 +46,7 @@ typedef void (Fl_Label_Measure_F)(const Fl_Label*, int&, int&); typedef void (Fl_Box_Draw_F)(int,int,int,int, Fl_Color); typedef void (*Fl_Timeout_Handler)(void*); +typedef void (*Fl_Awake_Handler)(void*); class FL_EXPORT Fl { Fl() {}; // no constructor! @@ -79,6 +80,14 @@ public: // should be private! static void (*idle)(); static void (*awake_cb)(void *); + static Fl_Awake_Handler *awake_ring_; + static void **awake_data_; + static int awake_ring_size_; + static int awake_ring_head_; + static int awake_ring_tail_; + + static int add_awake_handler_(Fl_Awake_Handler, void*); + static int get_awake_handler_(Fl_Awake_Handler&, void*&); static const char* scheme_; static Fl_Image* scheme_bg_; @@ -267,6 +276,7 @@ public: static void lock(); static void unlock(); static void awake(void* message = 0); + static int awake(Fl_Awake_Handler cb, void* message = 0); static void set_awake_cb(void (*cb)(void *)) { awake_cb = cb; } static void* thread_message(); |
