multithreading - Ada Thread Switching Using GtkAda -


a task created doesn't appear relinquishing control main thread run. i'm not sure why. since first attempt use multithreading in ada (under gnat gtkada), sure missing basic principle here.

my main looks this:

procedure main begin    test_gui.gui_task.gui_initialize;    test_gui.simple_switch_test;    msg("done"); end; 

in package test_gui, spec , body code this:

task type gui_type   entry gui_initialize;   entry gui_reset_switch_to_1;   entry gui_display_message(message : string);   entry gui_write_debug; end gui_type;  gui_task : gui_type; 

and

task body gui_type begin    loop       select          accept gui_initialize              initialize;          end gui_initialize;       or           accept gui_reset_switch_to_1              reset_switch_to_1;          end gui_reset_switch_to_1;       or          accept gui_display_message (message : in string)             display_message(message);          end gui_display_message;       or          accept gui_write_debug              debug_label.set_label(debug_label_text);                         end gui_write_debug;       else          gdk.threads.enter;          dead := gtk.main.main_iteration;          gdk.threads.leave;         delay 0.01;      end select;   end loop; end gui_type; 

the second method, simple_switch_test, called main this, invokes call gui task within redisplay_item_and_get_switches.

procedure simple_switch_test    text  : string(1..80) := (others => ' ');   msg   : string(1..16);  begin   loop      count := count + 1;      copy_string(integer'image(count), text);      in 1..16 loop         msg(i) := text(i);      end loop;       redisplay_item_and_get_switches(msg);       copy_string("some stuff.."), debug_label_text );       gui_task.gui_write_debug;       delay 0.01;    end loop;  end; 

initialization works , gui functions, callbacks working. however, after first call redisplay_item_and_get_switches simple_switch_test puts code gui task loop, never leaves else clause, except handle callbacks.

consequently, never gets call gui_task.gui_write_debug , continue code in main task.

i have verified in debugger.

i thought delays in each loop suspend associated task, don't understand correctly. code fixable without many changes? (i'm hoping got basic skeleton of tasking implemented right.) missing or wrong it?

the problem see gtkada layered on top of non-ada product, gtk, doesn't support ada's tasking model.

according dmitry kazakov's "gtkada contributions" library :

gtk+ known task unsafe. in particular, calls need made same task (thread).

i have no better suggestion read documentation @ link, first section "1. tasking gtk+" contains example in section 1.1, , - if find helpful - download , use support library.

(if people think should comment, i'll make so)


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -