Elm examples: add win32 thread examples, remove some whitespaces in the corresponding pthread code, and rework a bit Makefile.am

SVN revision: 69580
This commit is contained in:
Vincent Torri 2012-03-23 07:23:26 +00:00
parent f1c642d3d0
commit 91f8728bb4
11 changed files with 738 additions and 319 deletions

View File

@ -2,15 +2,15 @@ MAINTAINERCLEANFILES = Makefile.in
.PHONY: screenshots
examplesdir = $(datadir)/$(PACKAGE)/examples
filesdir = $(datadir)/$(PACKAGE)/examples
examplesdir = $(pkgdatadir)/examples
filesdir = $(pkgdatadir)/examples
files_DATA =
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_builddir)/src/lib \
-DPACKAGE_DATA_DIR="\"$(datadir)/elementary\"" \
-DPACKAGE_DATA_DIR="\"$(pkgdatadir)\"" \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
@ELEMENTARY_EDBUS_CFLAGS@ \
@ -21,10 +21,10 @@ AM_CPPFLAGS = \
@ELEMENTARY_CFLAGS@
LDADD = \
@ELEMENTARY_LIBS@ \
@ELEMENTARY_ETHUMB_LIBS@ \
@ELEMENTARY_X_LIBS@ \
$(top_builddir)/src/lib/libelementary.la
@ELEMENTARY_LIBS@ \
@ELEMENTARY_ETHUMB_LIBS@ \
@ELEMENTARY_X_LIBS@ \
$(top_builddir)/src/lib/libelementary.la
EDJE_CC = @edje_cc@
EDJE_FLAGS_VERBOSE_ =
@ -33,102 +33,104 @@ EDJE_FLAGS_VERBOSE_1 = -v
EDJE_FLAGS = $(EDJE_FLAGS_$(V))
SRCS = \
actionslider_example_01.c \
bubble_example_01.c \
button_example_00.c \
button_example_01.c \
check_example_01.c \
colorselector_example_01.c \
frame_example_01.c \
transit_example_01.c \
transit_example_02.c \
transit_example_03.c \
transit_example_04.c \
bg_example_01.c \
bg_example_02.c \
bg_example_03.c \
box_example_02.c \
flip_example_01.c \
general_funcs_example.c \
hover_example_01.c \
hoversel_example_01.c \
label_example_01.c \
theme_example_01.c \
theme_example_02.c \
calendar_example_01.c \
calendar_example_02.c \
calendar_example_03.c \
calendar_example_04.c \
calendar_example_05.c \
calendar_example_06.c \
datetime_example.c \
map_example_01.c \
map_example_02.c \
map_example_03.c \
toolbar_example_01.c \
toolbar_example_02.c \
toolbar_example_03.c \
spinner_example.c \
clock_example.c \
dayselector_example.c \
mapbuf_example.c \
conformant_example_01.c \
conformant_example_02.c \
image_example_01.c \
icon_example_01.c \
layout_example_01.c \
layout_example_02.c \
layout_example_03.c \
list_example_01.c \
list_example_02.c \
list_example_03.c \
segment_control_example.c \
flipselector_example.c \
fileselector_example.c \
fileselector_button_example.c \
fileselector_entry_example.c \
diskselector_example_01.c \
diskselector_example_02.c \
index_example_01.c \
index_example_02.c \
genlist_example_01.c \
genlist_example_02.c \
genlist_example_03.c \
genlist_example_04.c \
genlist_example_05.c \
theme_example.edc \
layout_example.edc \
slider_example.c \
panes_example.c \
ctxpopup_example_01.c \
separator_example_01.c \
radio_example_01.c \
panel_example_01.c \
gengrid_example.c \
entry_example.c \
slideshow_example.c \
progressbar_example.c \
notify_example_01.c \
photocam_example_01.c \
popup_example_01.c \
popup_example_02.c \
popup_example_03.c \
inwin_example.c \
scroller_example_01.c \
table_example_01.c \
table_example_02.c \
menu_example_01.c \
thumb_example_01.c \
web_example.c \
win_example.c \
efl_thread_1.c \
efl_thread_2.c \
efl_thread_3.c \
efl_thread_4.c \
efl_thread_5.c \
efl_thread_6.c
examples_PROGRAMS =
actionslider_example_01.c \
bg_example_01.c \
bg_example_02.c \
bg_example_03.c \
box_example_02.c \
bubble_example_01.c \
button_example_00.c \
button_example_01.c \
calendar_example_01.c \
calendar_example_02.c \
calendar_example_03.c \
calendar_example_04.c \
calendar_example_05.c \
calendar_example_06.c \
check_example_01.c \
clock_example.c \
colorselector_example_01.c \
conformant_example_01.c \
conformant_example_02.c \
ctxpopup_example_01.c \
datetime_example.c \
dayselector_example.c \
diskselector_example_01.c \
diskselector_example_02.c \
efl_thread_1.c \
efl_thread_2.c \
efl_thread_3.c \
efl_thread_4.c \
efl_thread_5.c \
efl_thread_6.c \
efl_thread_win32_1.c \
efl_thread_win32_2.c \
efl_thread_win32_3.c \
efl_thread_win32_4.c \
entry_example.c \
fileselector_button_example.c \
fileselector_entry_example.c \
fileselector_example.c \
flip_example_01.c \
flipselector_example.c \
frame_example_01.c \
general_funcs_example.c \
gengrid_example.c \
genlist_example_01.c \
genlist_example_02.c \
genlist_example_03.c \
genlist_example_04.c \
genlist_example_05.c \
hover_example_01.c \
hoversel_example_01.c \
icon_example_01.c \
image_example_01.c \
index_example_01.c \
index_example_02.c \
inwin_example.c \
label_example_01.c \
layout_example.edc \
layout_example_01.c \
layout_example_02.c \
layout_example_03.c \
list_example_01.c \
list_example_02.c \
list_example_03.c \
map_example_01.c \
map_example_02.c \
map_example_03.c \
mapbuf_example.c \
menu_example_01.c \
notify_example_01.c \
panes_example.c \
panel_example_01.c \
photocam_example_01.c \
popup_example_01.c \
popup_example_02.c \
popup_example_03.c \
progressbar_example.c \
radio_example_01.c \
segment_control_example.c \
separator_example_01.c \
slider_example.c \
slideshow_example.c \
spinner_example.c \
scroller_example_01.c \
table_example_01.c \
table_example_02.c \
theme_example.edc \
theme_example_01.c \
theme_example_02.c \
thumb_example_01.c \
toolbar_example_01.c \
toolbar_example_02.c \
toolbar_example_03.c \
transit_example_01.c \
transit_example_02.c \
transit_example_03.c \
transit_example_04.c \
web_example.c \
win_example.c
.edc.edj:
$(EDJE_CC) $(EDJE_FLAGS) $< $@
@ -146,183 +148,195 @@ files_DATA += \
clean-local:
rm -f *.edj
examples_PROGRAMS += \
actionslider_example_01 \
bubble_example_01 \
button_example_00 \
button_example_01 \
check_example_01 \
colorselector_example_01 \
frame_example_01 \
transit_example_01 \
transit_example_02 \
transit_example_03 \
transit_example_04 \
bg_example_01 \
bg_example_02 \
bg_example_03 \
box_example_02 \
flip_example_01 \
general_funcs_example \
hover_example_01 \
hoversel_example_01 \
label_example_01 \
theme_example_01 \
theme_example_02 \
calendar_example_01 \
calendar_example_02 \
calendar_example_03 \
calendar_example_04 \
calendar_example_05 \
calendar_example_06 \
datetime_example \
map_example_01 \
map_example_02 \
map_example_03 \
toolbar_example_01 \
toolbar_example_02 \
toolbar_example_03 \
spinner_example \
clock_example \
dayselector_example \
mapbuf_example \
conformant_example_01 \
conformant_example_02 \
image_example_01 \
diskselector_example_01 \
diskselector_example_02 \
icon_example_01 \
layout_example_01 \
layout_example_02 \
layout_example_03 \
list_example_01 \
list_example_02 \
list_example_03 \
segment_control_example \
slider_example \
panes_example \
ctxpopup_example_01 \
flipselector_example \
fileselector_example \
fileselector_button_example \
fileselector_entry_example \
index_example_01 \
index_example_02 \
separator_example_01 \
radio_example_01 \
panel_example_01 \
gengrid_example \
genlist_example_01 \
genlist_example_02 \
genlist_example_03 \
genlist_example_04 \
genlist_example_05 \
entry_example \
slideshow_example \
progressbar_example \
notify_example_01 \
photocam_example_01 \
popup_example_01 \
popup_example_02 \
popup_example_03 \
inwin_example \
scroller_example_01 \
table_example_01 \
table_example_02 \
menu_example_01 \
thumb_example_01 \
web_example \
win_example \
efl_thread_1 \
efl_thread_2 \
efl_thread_3 \
efl_thread_4 \
efl_thread_5 \
efl_thread_6
examples_PROGRAMS = \
actionslider_example_01 \
bg_example_01 \
bg_example_02 \
bg_example_03 \
box_example_02 \
bubble_example_01 \
button_example_00 \
button_example_01 \
calendar_example_01 \
calendar_example_02 \
calendar_example_03 \
calendar_example_04 \
calendar_example_05 \
calendar_example_06 \
check_example_01 \
clock_example \
colorselector_example_01 \
conformant_example_01 \
conformant_example_02 \
ctxpopup_example_01 \
datetime_example \
dayselector_example \
diskselector_example_01 \
diskselector_example_02 \
efl_thread_1 \
efl_thread_2 \
efl_thread_3 \
efl_thread_4 \
efl_thread_5 \
efl_thread_6 \
entry_example \
fileselector_button_example \
fileselector_entry_example \
fileselector_example \
flip_example_01 \
flipselector_example \
frame_example_01 \
general_funcs_example \
gengrid_example \
genlist_example_01 \
genlist_example_02 \
genlist_example_03 \
genlist_example_04 \
genlist_example_05 \
hover_example_01 \
hoversel_example_01 \
icon_example_01 \
image_example_01 \
index_example_01 \
index_example_02 \
inwin_example \
label_example_01 \
layout_example_01 \
layout_example_02 \
layout_example_03 \
list_example_01 \
list_example_02 \
list_example_03 \
map_example_01 \
map_example_02 \
map_example_03 \
mapbuf_example \
menu_example_01 \
notify_example_01 \
panes_example \
panel_example_01 \
photocam_example_01 \
popup_example_01 \
popup_example_02 \
popup_example_03 \
progressbar_example \
radio_example_01 \
segment_control_example \
separator_example_01 \
slider_example \
slideshow_example \
spinner_example \
scroller_example_01 \
table_example_01 \
table_example_02 \
theme_example_01 \
theme_example_02 \
thumb_example_01 \
toolbar_example_01 \
toolbar_example_02 \
toolbar_example_03 \
transit_example_01 \
transit_example_02 \
transit_example_03 \
transit_example_04 \
web_example \
win_example
if ELEMENTARY_WINDOWS_BUILD
efl_thread_1_SOURCES = efl_thread_win32_1.c
efl_thread_2_SOURCES = efl_thread_win32_2.c
efl_thread_3_SOURCES = efl_thread_win32_3.c
efl_thread_4_SOURCES = efl_thread_win32_4.c
else
efl_thread_1_SOURCES = efl_thread_1.c
efl_thread_2_SOURCES = efl_thread_2.c
efl_thread_3_SOURCES = efl_thread_3.c
efl_thread_4_SOURCES = efl_thread_4.c
endif
# This variable will hold the list of screenshots that will be made
# by "make screenshots". Each item in the list is of the form:
# <example executable>:<screenshot filename>:<delay in seconds>
SCREENSHOTS = \
actionslider_example_01:actionslider_01.png:0.0 \
bg_example_02:bg_01.png:0.0 \
box_example_02:box_example_02.png:1.3 \
bubble_example_01:bubble_example_01.png:0.0 \
button_example_00:button_00.png:0.0 \
button_example_01:button_01.png:0.0 \
check_example_01:check_example_01.png:0.0 \
colorselector_example_01:colorselector_example_01.png:0.0 \
animator_example_01:animator_example_01.png:0.2 \
animator_example_01:animator_example_02.png:0.5 \
animator_example_01:animator_example_03.png:0.9 \
flip_example_01:flip_example_01.png:0.0 \
frame_example_01:frame_example_01.png:0.0 \
hover_example_01:hover_example_01.png:0.0 \
hoversel_example_01:hoversel_example_01.png:0.0 \
label_example_01:label_example_01.png:0.0 \
theme_example_01:theme_example_01.png:0.0 \
conformant_example_01:conformant_example_01.png:0.0 \
conformant_example_02:conformant_example_02.png:0.0 \
calendar_example_01:calendar_example_01.png:0.0 \
calendar_example_02:calendar_example_02.png:0.0 \
calendar_example_03:calendar_example_03.png:0.0 \
calendar_example_04:calendar_example_04.png:0.0 \
calendar_example_05:calendar_example_05.png:0.0 \
calendar_example_06:calendar_example_06.png:0.0 \
datetime_example:datetime_example.png:0.0 \
map_example_01:map_example_01.png:2 \
map_example_02:map_example_02.png:2.5 \
map_example_03:map_example_03.png:2 \
toolbar_example_01:toolbar_example_01.png:0.0 \
toolbar_example_02:toolbar_example_02.png:1 \
toolbar_example_03:toolbar_example_03.png:1 \
spinner_example:spinner_example.png:0.0 \
clock_example:clock_example.png:0.5 \
dayselector_example:dayselector_example.png:0.0 \
mapbuf_example:mapbuf_example.png:0.0 \
image_example_01:image_example_01.png:0.0 \
diskselector_example_01:diskselector_example_01.png:0.2 \
diskselector_example_02:diskselector_example_02.png:0.2 \
icon_example_01:icon_example_01.png:0.0 \
layout_example_01:layout_example_01.png:0.0 \
layout_example_02:layout_example_02.png:0.0 \
layout_example_03:layout_example_03.png:0.0 \
list_example_01:list_example_01.png:0.0 \
list_example_02:list_example_02.png:0.0 \
list_example_03:list_example_03.png:0.0 \
segment_control_example:segment_control_example.png:0.0 \
flipselector_example:flipselector_example.png:0.0 \
fileselector_example:fileselector_example.png:0.0 \
index_example_02:index_example_03.png:0.3 \
slider_example:slider_example.png:0.0 \
panes_example:panes_example.png:0.0 \
ctxpopup_example_01:ctxpopup_example_01.png:0.0 \
separator_example_01:separator_example_01.png:0.0 \
radio_example_01:radio_example_01.png:0.0 \
panel_example_01:panel_example_01.png:0.0 \
gengrid_example:gengrid_example.png:0.0 \
genlist_example_01:genlist_example_01.png:0.1 \
genlist_example_02:genlist_example_02.png:0.1 \
genlist_example_03:genlist_example_03.png:0.1 \
genlist_example_04:genlist_example_04.png:0.1 \
genlist_example_05:genlist_example_05.png:0.1 \
thumb_example_01:thumb_example_01.png:0.5 \
entry_example:entry_example.png:0.0 \
progressbar_example:progressbar_example.png:0.0 \
notify_example_01:notify_example_01.png:0.0 \
notify_example_01:notify_example_01_a.png:6.0 \
popup_example_01:popup_example_01.png:1.0 \
popup_example_01:popup_example_01_a.png:6.0 \
popup_example_02:popup_example_02.png:0.2 \
popup_example_03:popup_example_03.png:0.2 \
slideshow_example:slideshow_example.png:1.0 \
photocam_example_01:photocam_example_01.png:3 \
scroller_example_01:scroller_example_01.png:0.0 \
inwin_example:inwin_example.png:0.0 \
inwin_example:inwin_example_a.png:0.2 \
table_example_01:table_example_01.png:0.0 \
table_example_02:table_example_02.png:0.0 \
menu_example_01:menu_example_01.png:0.5
actionslider_example_01:actionslider_01.png:0.0 \
bg_example_02:bg_01.png:0.0 \
box_example_02:box_example_02.png:1.3 \
bubble_example_01:bubble_example_01.png:0.0 \
button_example_00:button_00.png:0.0 \
button_example_01:button_01.png:0.0 \
check_example_01:check_example_01.png:0.0 \
colorselector_example_01:colorselector_example_01.png:0.0 \
animator_example_01:animator_example_01.png:0.2 \
animator_example_01:animator_example_02.png:0.5 \
animator_example_01:animator_example_03.png:0.9 \
flip_example_01:flip_example_01.png:0.0 \
frame_example_01:frame_example_01.png:0.0 \
hover_example_01:hover_example_01.png:0.0 \
hoversel_example_01:hoversel_example_01.png:0.0 \
label_example_01:label_example_01.png:0.0 \
theme_example_01:theme_example_01.png:0.0 \
conformant_example_01:conformant_example_01.png:0.0 \
conformant_example_02:conformant_example_02.png:0.0 \
calendar_example_01:calendar_example_01.png:0.0 \
calendar_example_02:calendar_example_02.png:0.0 \
calendar_example_03:calendar_example_03.png:0.0 \
calendar_example_04:calendar_example_04.png:0.0 \
calendar_example_05:calendar_example_05.png:0.0 \
calendar_example_06:calendar_example_06.png:0.0 \
datetime_example:datetime_example.png:0.0 \
map_example_01:map_example_01.png:2 \
map_example_02:map_example_02.png:2.5 \
map_example_03:map_example_03.png:2 \
toolbar_example_01:toolbar_example_01.png:0.0 \
toolbar_example_02:toolbar_example_02.png:1 \
toolbar_example_03:toolbar_example_03.png:1 \
spinner_example:spinner_example.png:0.0 \
clock_example:clock_example.png:0.5 \
dayselector_example:dayselector_example.png:0.0 \
mapbuf_example:mapbuf_example.png:0.0 \
image_example_01:image_example_01.png:0.0 \
diskselector_example_01:diskselector_example_01.png:0.2 \
diskselector_example_02:diskselector_example_02.png:0.2 \
icon_example_01:icon_example_01.png:0.0 \
layout_example_01:layout_example_01.png:0.0 \
layout_example_02:layout_example_02.png:0.0 \
layout_example_03:layout_example_03.png:0.0 \
list_example_01:list_example_01.png:0.0 \
list_example_02:list_example_02.png:0.0 \
list_example_03:list_example_03.png:0.0 \
segment_control_example:segment_control_example.png:0.0 \
flipselector_example:flipselector_example.png:0.0 \
fileselector_example:fileselector_example.png:0.0 \
index_example_02:index_example_03.png:0.3 \
slider_example:slider_example.png:0.0 \
panes_example:panes_example.png:0.0 \
ctxpopup_example_01:ctxpopup_example_01.png:0.0 \
separator_example_01:separator_example_01.png:0.0 \
radio_example_01:radio_example_01.png:0.0 \
panel_example_01:panel_example_01.png:0.0 \
gengrid_example:gengrid_example.png:0.0 \
genlist_example_01:genlist_example_01.png:0.1 \
genlist_example_02:genlist_example_02.png:0.1 \
genlist_example_03:genlist_example_03.png:0.1 \
genlist_example_04:genlist_example_04.png:0.1 \
genlist_example_05:genlist_example_05.png:0.1 \
thumb_example_01:thumb_example_01.png:0.5 \
entry_example:entry_example.png:0.0 \
progressbar_example:progressbar_example.png:0.0 \
notify_example_01:notify_example_01.png:0.0 \
notify_example_01:notify_example_01_a.png:6.0 \
popup_example_01:popup_example_01.png:1.0 \
popup_example_01:popup_example_01_a.png:6.0 \
popup_example_02:popup_example_02.png:0.2 \
popup_example_03:popup_example_03.png:0.2 \
slideshow_example:slideshow_example.png:1.0 \
photocam_example_01:photocam_example_01.png:3 \
scroller_example_01:scroller_example_01.png:0.0 \
inwin_example:inwin_example.png:0.0 \
inwin_example:inwin_example_a.png:0.2 \
table_example_01:table_example_01.png:0.0 \
table_example_02:table_example_02.png:0.0 \
menu_example_01:menu_example_01.png:0.5
HTML_SS_DIR=$(top_builddir)/doc/html/screenshots
LATEX_SS_DIR=$(top_builddir)/doc/latex/screenshots

View File

@ -14,13 +14,13 @@ static void *
my_thread_run(void *arg)
{
double t = 0.0;
for (;;)
{
ecore_thread_main_loop_begin(); // begin critical
{ // indented for illustration of "critical" block
Evas_Coord x, y;
x = 200 + (200 * sin(t));
y = 200 + (200 * cos(t));
evas_object_move(rect, x - 50, y - 50);
@ -38,7 +38,7 @@ static void
my_thread_new(void)
{
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0)
perror("pthread_attr_init");
if (pthread_create(&thread_id, &attr, my_thread_run, NULL) != 0)
@ -49,28 +49,28 @@ int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-1", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 1");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}

View File

@ -25,7 +25,7 @@ my_thread_run(void *arg)
for (;;)
{
struct info *inf = malloc(sizeof(struct info));
if (inf)
{
inf->x = 200 + (200 * sin(t));
@ -45,7 +45,7 @@ static void
my_thread_new(void)
{
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0)
perror("pthread_attr_init");
if (pthread_create(&thread_id, &attr, my_thread_run, NULL) != 0)
@ -65,30 +65,30 @@ int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-2", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 2");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}
ELM_MAIN()

View File

@ -26,7 +26,7 @@ my_thread_run(void *arg)
for (;;)
{
struct info *inf = malloc(sizeof(struct info));
if (inf)
{
inf->x = 200 + (200 * sin(t));
@ -48,7 +48,7 @@ static void
my_thread_new(void)
{
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0)
perror("pthread_attr_init");
if (pthread_create(&thread_id, &attr, my_thread_run, NULL) != 0)
@ -67,31 +67,30 @@ int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-3", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 3");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}
ELM_MAIN()

View File

@ -29,7 +29,7 @@ my_thread_run(void *arg)
{
struct info *inf = malloc(sizeof(struct info));
int do_exit;
if (inf)
{
inf->x = 200 + (200 * sin(t));
@ -87,14 +87,14 @@ int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-4", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 4");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
@ -108,13 +108,12 @@ elm_main(int argc, char **argv)
// the thread
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, down, NULL);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}
ELM_MAIN()

View File

@ -12,18 +12,18 @@ struct info
double x, y;
};
// BEGIN - code running in my custom pthread instance
// BEGIN - code running in my custom thread instance
//
static void
th_do(void *data, Ecore_Thread *th)
{
double t = 0.0;
// inside our "do" function for the ecore thread, lets do the real work
for (;;)
{
struct info *inf = malloc(sizeof(struct info));
if (inf)
{
inf->x = 200 + (200 * sin(t));
@ -41,7 +41,7 @@ th_do(void *data, Ecore_Thread *th)
}
}
//
// END - code running in my custom pthread instance
// END - code running in my custom thread instance
static void // when mainloop gets feedback from worker
th_feedback(void *data, Ecore_Thread *th, void *msg)
@ -67,26 +67,26 @@ int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-5", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 5");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, down, NULL);
rect = o;
// explicitly create ecore thread to do some "work on the side" and pass
// in NULL as data ptr to callbacks and true at the end means to actually
// make a new thread and not use the thread pool (there is a thread pool
@ -94,7 +94,7 @@ elm_main(int argc, char **argv)
// overload the cpu's with more work than you actually have processing
// units *IF* your threads do actually spend their time doing actual
// heavy computation)
th = ecore_thread_feedback_run(th_do, th_feedback, th_end, th_cancel,
th = ecore_thread_feedback_run(th_do, th_feedback, th_end, th_cancel,
NULL, EINA_TRUE);
elm_run();
return 0;

View File

@ -11,7 +11,7 @@ struct info
int *pix;
};
// BEGIN - code running in my custom pthread instance
// BEGIN - code running in my custom thread instance
//
static void
mandel(int *pix, int w, int h)
@ -48,12 +48,12 @@ mandel(int *pix, int w, int h)
}
val = (((x * x) + (y * y)) * 2.55) / 100.0;
if (val > 255) val = 255;
if (iteration >= 99999)
if (iteration >= 99999)
{
rr = (r * val) / 255;
gg = (g * val) / 255;
bb = (b * val) / 255;
pix[(hy * w) + hx] =
pix[(hy * w) + hx] =
(val << 24) | (rr << 16) | (gg << 8) | (bb);
}
else
@ -71,7 +71,7 @@ th_do(void *data, Ecore_Thread *th)
mandel(inf->pix, 256, 256);
}
//
// END - code running in my custom pthread instance
// END - code running in my custom thread instance
static void // thread job finished - collect results and put in img obj
th_end(void *data, Ecore_Thread *th)
@ -165,4 +165,3 @@ elm_main(int argc, char **argv)
}
ELM_MAIN()

View File

@ -0,0 +1,83 @@
//Compile with:
//gcc -o efl_thread_1 efl_thread_win32_1.c -g `pkg-config --cflags --libs elementary`
#include <Elementary.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static Evas_Object *win = NULL;
static Evas_Object *rect = NULL;
static HANDLE thread;
// BEGIN - code running in my custom win32 thread instance
//
static DWORD WINAPI
my_thread_run(LPVOID arg)
{
double t = 0.0;
for (;;)
{
ecore_thread_main_loop_begin(); // begin critical
{ // indented for illustration of "critical" block
Evas_Coord x, y;
x = 200 + (200 * sin(t));
y = 200 + (200 * cos(t));
evas_object_move(rect, x - 50, y - 50);
}
ecore_thread_main_loop_end(); // end critical
usleep(1000);
t += 0.02;
}
return 0;
}
//
// END - code running in my custom win32 thread instance
static void
my_thread_new(void)
{
thread = CreateThread(NULL, 0, my_thread_run, NULL, 0, NULL);
if (!thread)
{
char *str = evil_last_error_get();
if (str)
{
fprintf("thread creation failed: %s\n", str);
free(str);
}
}
}
int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-1", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 1");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}
ELM_MAIN()

View File

@ -0,0 +1,99 @@
//Compile with:
//gcc -o efl_thread_2 efl_thread_win32_2.c -g `pkg-config --cflags --libs elementary`
#include <Elementary.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static Evas_Object *win = NULL;
static Evas_Object *rect = NULL;
struct info
{
double x, y;
};
static void *my_thread_mainloop_code(void *data);
static HANDLE thread;
// BEGIN - code running in my custom win32 thread instance
//
static DWORD WINAPI
my_thread_run(LPVOID arg)
{
double t = 0.0;
for (;;)
{
struct info *inf = malloc(sizeof(struct info));
if (inf)
{
inf->x = 200 + (200 * sin(t));
inf->y = 200 + (200 * cos(t));
ecore_main_loop_thread_safe_call_sync
(my_thread_mainloop_code, inf);
}
// and sleep and loop
usleep(1000);
t += 0.02;
}
return 0;
}
//
// END - code running in my custom win32 thread instance
static void
my_thread_new(void)
{
thread = CreateThread(NULL, 0, my_thread_run, NULL, 0, NULL);
if (!thread)
{
char *str = evil_last_error_get();
if (str)
{
fprintf("thread creation failed: %s\n", str);
free(str);
}
}
}
static void *
my_thread_mainloop_code(void *data)
{
struct info *inf = data;
evas_object_move(rect, inf->x - 50, inf->y - 50);
free(inf);
return NULL;
}
int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-2", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 2");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}
ELM_MAIN()

View File

@ -0,0 +1,101 @@
//Compile with:
//gcc -o efl_thread_3 efl_thread_win32_3.c -g `pkg-config --cflags --libs elementary`
#include <Elementary.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static Evas_Object *win = NULL;
static Evas_Object *rect = NULL;
struct info
{
double x, y;
};
static void my_thread_mainloop_code(void *data);
static HANDLE thread;
// BEGIN - code running in my custom win32 thread instance
//
static DWORD WINAPI
my_thread_run(LPVOID arg)
{
double t = 0.0;
// inside the thread function lets loop forever incrimenting a time point
for (;;)
{
struct info *inf = malloc(sizeof(struct info));
if (inf)
{
inf->x = 200 + (200 * sin(t));
inf->y = 200 + (200 * cos(t));
// now call a function in the mainloop and pass it our allocated
// data that it will free when it gets it
ecore_main_loop_thread_safe_call_async
(my_thread_mainloop_code, inf);
}
// and sleep and loop
usleep(1000);
t += 0.02;
}
return NULL;
}
//
// END - code running in my custom win32 thread instance
static void
my_thread_new(void)
{
thread = CreateThread(NULL, 0, my_thread_run, NULL, 0, NULL);
if (!thread)
{
char *str = evil_last_error_get();
if (str)
{
fprintf("thread creation failed: %s\n", str);
free(str);
}
}
}
static void
my_thread_mainloop_code(void *data)
{
struct info *inf = data;
evas_object_move(rect, inf->x - 50, inf->y - 50);
free(inf);
}
int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-3", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 3");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}
ELM_MAIN()

View File

@ -0,0 +1,125 @@
//Compile with:
//gcc -o efl_thread_4 efl_thread_win32_4.c -g `pkg-config --cflags --libs elementary`
#include <Elementary.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static Evas_Object *win = NULL;
static Evas_Object *rect = NULL;
struct info
{
double x, y;
};
static void my_thread_mainloop_code(void *data);
static HANDLE thread;
static CRITICAL_SECTION lock;
static int th_exit = 0;
// BEGIN - code running in my custom win32 thread instance
//
static DWORD WINAPI
my_thread_run(LPVOID arg)
{
double t = 0.0;
// inside the thread function lets loop forever incrimenting a time point
for (;;)
{
struct info *inf = malloc(sizeof(struct info));
int do_exit;
if (inf)
{
inf->x = 200 + (200 * sin(t));
inf->y = 200 + (200 * cos(t));
// now call a function in the mainloop and pass it our allocated
// data that it will free when it gets it
ecore_main_loop_thread_safe_call_async
(my_thread_mainloop_code, inf);
}
// and sleep and loop
usleep(1000);
t += 0.02;
// in case someone has asked us to cancel - then cancel this loop
// co-operatively (cancelling is co-operative)
EnterCriticalSection(&lock);
do_exit = th_exit;
LeaveCriticalSection(&lock);
if (do_exit) break;
}
DeleteCriticalSection(&lock);
return NULL;
}
//
// END - code running in my custom win32 thread instance
static void
my_thread_new(void)
{
InitializeCriticalSection(&lock);
thread = CreateThread(NULL, 0, my_thread_run, NULL, 0, NULL);
if (!thread)
{
char *str = evil_last_error_get();
if (str)
{
fprintf("thread creation failed: %s\n", str);
free(str);
}
}
}
static void
my_thread_mainloop_code(void *data)
{
struct info *inf = data;
evas_object_move(rect, inf->x - 50, inf->y - 50);
free(inf);
}
// just test cancelling the thread
static void
down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
EnterCriticalSection(&lock);
th_exit = 1;
LeaveCriticalSection(&lock);
}
int
elm_main(int argc, char **argv)
{
Evas_Object *o, *bg;
win = elm_win_add(NULL, "efl-thread-4", ELM_WIN_BASIC);
elm_win_title_set(win, "EFL Thread 4");
elm_win_autodel_set(win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_resize(win, 400, 400);
evas_object_show(win);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 50, 80, 180, 255);
evas_object_resize(o, 100, 100);
evas_object_show(o);
// new in the examples - we have a mouse down on the blue box cancel
// the thread
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, down, NULL);
rect = o;
// create custom thread to do some "work on the side"
my_thread_new();
elm_run();
return 0;
}
ELM_MAIN()