summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorHaegeun Park <haegeun.park@samsung.com>2017-01-04 11:45:56 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-01-04 15:30:21 +0900
commit0ac95c40bcac812d1249b53814b94ccda3603cf9 (patch)
treea862b52f78789e0aef17aace426ad2c9d00d6d33 /src/lib/evas/common
parenta6c1c2d08fe10f63911c5dd3880eadbb4ae4316b (diff)
[Evas GL Thread 1] evas: Fixed indentation of evas_thread_render.c
Summary: @fix Change-Id: I411fe6d75dc7b15c0d7f19f165ea4b0cc3b28c12 Reviewers: sung, jpeg, cedric, raster Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4525
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_thread_render.c273
1 files changed, 137 insertions, 136 deletions
diff --git a/src/lib/evas/common/evas_thread_render.c b/src/lib/evas/common/evas_thread_render.c
index 03812b5128..85955669ac 100644
--- a/src/lib/evas/common/evas_thread_render.c
+++ b/src/lib/evas/common/evas_thread_render.c
@@ -63,13 +63,13 @@ out:
63EAPI void 63EAPI void
64evas_thread_cmd_enqueue(Evas_Thread_Command_Cb cb, void *data) 64evas_thread_cmd_enqueue(Evas_Thread_Command_Cb cb, void *data)
65{ 65{
66 evas_thread_queue_append(cb, data, EINA_FALSE); 66 evas_thread_queue_append(cb, data, EINA_FALSE);
67} 67}
68 68
69EAPI void 69EAPI void
70evas_thread_queue_flush(Evas_Thread_Command_Cb cb, void *data) 70evas_thread_queue_flush(Evas_Thread_Command_Cb cb, void *data)
71{ 71{
72 evas_thread_queue_append(cb, data, EINA_TRUE); 72 evas_thread_queue_append(cb, data, EINA_TRUE);
73} 73}
74 74
75static void* 75static void*
@@ -77,160 +77,161 @@ evas_thread_worker_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED)
77{ 77{
78 eina_thread_name_set(eina_thread_self(), "Eevas-thread-wk"); 78 eina_thread_name_set(eina_thread_self(), "Eevas-thread-wk");
79 while (1) 79 while (1)
80 { 80 {
81 Evas_Thread_Command *cmd; 81 Evas_Thread_Command *cmd;
82 unsigned int len, max; 82 unsigned int len, max;
83 83
84 eina_lock_take(&evas_thread_queue_lock); 84 eina_lock_take(&evas_thread_queue_lock);
85 85
86 while (!evas_thread_queue_ready) 86 while (!evas_thread_queue_ready)
87 { 87 {
88 if (exit_thread) 88 if (exit_thread)
89 { 89 {
90 eina_lock_release(&evas_thread_queue_lock); 90 eina_lock_release(&evas_thread_queue_lock);
91 goto out; 91 goto out;
92 } 92 }
93 eina_condition_wait(&evas_thread_queue_condition); 93 eina_condition_wait(&evas_thread_queue_condition);
94 } 94 }
95 95
96 if (!eina_inarray_count(&evas_thread_queue)) 96 if (!eina_inarray_count(&evas_thread_queue))
97 { 97 {
98 ERR("Signaled to find an empty queue. BUG!"); 98 ERR("Signaled to find an empty queue. BUG!");
99 evas_thread_queue_ready = EINA_FALSE; 99 evas_thread_queue_ready = EINA_FALSE;
100 eina_lock_release(&evas_thread_queue_lock); 100 eina_lock_release(&evas_thread_queue_lock);
101 continue; 101 continue;
102 } 102 }
103 103
104 cmd = evas_thread_queue.members; 104 cmd = evas_thread_queue.members;
105 evas_thread_queue.members = evas_thread_queue_cache; 105 evas_thread_queue.members = evas_thread_queue_cache;
106 evas_thread_queue_cache = cmd; 106 evas_thread_queue_cache = cmd;
107 107
108 max = evas_thread_queue.max; 108 max = evas_thread_queue.max;
109 evas_thread_queue.max = evas_thread_queue_cache_max; 109 evas_thread_queue.max = evas_thread_queue_cache_max;
110 evas_thread_queue_cache_max = max; 110 evas_thread_queue_cache_max = max;
111 111
112 len = evas_thread_queue.len; 112 len = evas_thread_queue.len;
113 evas_thread_queue.len = 0; 113 evas_thread_queue.len = 0;
114 114
115 evas_thread_queue_ready = EINA_FALSE; 115 evas_thread_queue_ready = EINA_FALSE;
116 116
117 eina_lock_release(&evas_thread_queue_lock); 117 eina_lock_release(&evas_thread_queue_lock);
118 118
119 DBG("Evas render thread command queue length: %u", len); 119 DBG("Evas render thread command queue length: %u", len);
120 120
121 eina_evlog("+thread", NULL, 0.0, NULL); 121 eina_evlog("+thread", NULL, 0.0, NULL);
122 while (len) 122 while (len)
123 { 123 {
124 assert(cmd->cb); 124 assert(cmd->cb);
125 125
126 eina_evlog("+thread_do", cmd->data, 0.0, NULL); 126 eina_evlog("+thread_do", cmd->data, 0.0, NULL);
127 cmd->cb(cmd->data); 127 cmd->cb(cmd->data);
128 eina_evlog("-thread_do", cmd->data, 0.0, NULL); 128 eina_evlog("-thread_do", cmd->data, 0.0, NULL);
129 129
130 cmd++; 130 cmd++;
131 len--; 131 len--;
132 } 132 }
133 eina_evlog("-thread", NULL, 0.0, NULL); 133 eina_evlog("-thread", NULL, 0.0, NULL);
134 } 134 }
135 135
136out: 136out:
137 /* WRN: add a memory barrier or use a lock if we add more code here */ 137 /* WRN: add a memory barrier or use a lock if we add more code here */
138 evas_thread_exited = 1; 138 evas_thread_exited = 1;
139 return NULL; 139 return NULL;
140} 140}
141 141
142int 142int
143evas_thread_init(void) 143evas_thread_init(void)
144{ 144{
145 if (init_count++) 145 if (init_count++)
146 return init_count; 146 return init_count;
147 147
148 exit_thread = EINA_FALSE; 148 exit_thread = EINA_FALSE;
149 evas_thread_exited = 0; 149 evas_thread_exited = 0;
150 150
151 if(!eina_threads_init()) 151 if(!eina_threads_init())
152 { 152 {
153 CRI("Could not init eina threads"); 153 CRI("Could not init eina threads");
154 goto fail_on_eina_thread_init; 154 goto fail_on_eina_thread_init;
155 } 155 }
156 156
157 eina_inarray_step_set(&evas_thread_queue, sizeof (Eina_Inarray), sizeof (Evas_Thread_Command), 128); 157 eina_inarray_step_set(&evas_thread_queue, sizeof (Eina_Inarray), sizeof (Evas_Thread_Command), 128);
158 158
159 if (!eina_lock_new(&evas_thread_queue_lock)) 159 if (!eina_lock_new(&evas_thread_queue_lock))
160 { 160 {
161 CRI("Could not create draw thread lock (%m)"); 161 CRI("Could not create draw thread lock (%m)");
162 goto fail_on_lock_creation; 162 goto fail_on_lock_creation;
163 } 163 }
164 if (!eina_condition_new(&evas_thread_queue_condition, &evas_thread_queue_lock)) 164 if (!eina_condition_new(&evas_thread_queue_condition, &evas_thread_queue_lock))
165 { 165 {
166 CRI("Could not create draw thread condition (%m)"); 166 CRI("Could not create draw thread condition (%m)");
167 goto fail_on_cond_creation; 167 goto fail_on_cond_creation;
168 } 168 }
169 169
170 if (!eina_thread_create(&evas_thread_worker, EINA_THREAD_NORMAL, -1, 170 if (!eina_thread_create(&evas_thread_worker, EINA_THREAD_NORMAL, -1,
171 evas_thread_worker_func, NULL)) 171 evas_thread_worker_func, NULL))
172 { 172 {
173 CRI("Could not create draw thread (%m)"); 173 CRI("Could not create draw thread (%m)");
174 goto fail_on_thread_creation; 174 goto fail_on_thread_creation;
175 } 175 }
176 176
177 return init_count; 177 return init_count;
178 178
179fail_on_thread_creation: 179fail_on_thread_creation:
180 evas_thread_worker = 0; 180 evas_thread_worker = 0;
181 eina_condition_free(&evas_thread_queue_condition); 181 eina_condition_free(&evas_thread_queue_condition);
182fail_on_cond_creation: 182fail_on_cond_creation:
183 eina_lock_free(&evas_thread_queue_lock); 183 eina_lock_free(&evas_thread_queue_lock);
184fail_on_lock_creation: 184fail_on_lock_creation:
185 eina_threads_shutdown(); 185 eina_threads_shutdown();
186fail_on_eina_thread_init: 186fail_on_eina_thread_init:
187 exit_thread = EINA_TRUE; 187 exit_thread = EINA_TRUE;
188 evas_thread_exited = 1; 188 evas_thread_exited = 1;
189 return --init_count; 189 return --init_count;
190} 190}
191 191
192int 192int
193evas_thread_shutdown(void) 193evas_thread_shutdown(void)
194{ 194{
195 double to = 0 ; 195 double to = 0 ;
196 196
197 if (init_count <= 0) 197 if (init_count <= 0)
198 { 198 {
199 ERR("Too many calls to shutdown, ignored."); 199 ERR("Too many calls to shutdown, ignored.");
200 return 0; 200 return 0;
201 } 201 }
202 202
203 if (--init_count) 203 if (--init_count)
204 return init_count; 204 return init_count;
205 205
206 eina_lock_take(&evas_thread_queue_lock); 206 eina_lock_take(&evas_thread_queue_lock);
207 207
208 exit_thread = EINA_TRUE; 208 exit_thread = EINA_TRUE;
209 eina_condition_signal(&evas_thread_queue_condition); 209 eina_condition_signal(&evas_thread_queue_condition);
210 210
211 eina_lock_release(&evas_thread_queue_lock); 211 eina_lock_release(&evas_thread_queue_lock);
212 _shutdown_timeout(&to, SHUTDOWN_TIMEOUT_RESET, SHUTDOWN_TIMEOUT); 212
213 while (!evas_thread_exited && (evas_async_events_process() != -1)) 213 _shutdown_timeout(&to, SHUTDOWN_TIMEOUT_RESET, SHUTDOWN_TIMEOUT);
214 { 214 while (!evas_thread_exited && (evas_async_events_process() != -1))
215 if(_shutdown_timeout(&to, SHUTDOWN_TIMEOUT_CHECK, SHUTDOWN_TIMEOUT)) 215 {
216 { 216 if(_shutdown_timeout(&to, SHUTDOWN_TIMEOUT_CHECK, SHUTDOWN_TIMEOUT))
217 CRI("Timeout shutdown thread. Skipping thread_join. Some resources could be leaked"); 217 {
218 goto timeout_shutdown; 218 CRI("Timeout shutdown thread. Skipping thread_join. Some resources could be leaked");
219 } 219 goto timeout_shutdown;
220 } 220 }
221 221 }
222 eina_thread_join(evas_thread_worker); 222
223 eina_thread_join(evas_thread_worker);
223timeout_shutdown: 224timeout_shutdown:
224 eina_lock_free(&evas_thread_queue_lock); 225 eina_lock_free(&evas_thread_queue_lock);
225 eina_condition_free(&evas_thread_queue_condition); 226 eina_condition_free(&evas_thread_queue_condition);
226 227
227 evas_thread_worker = 0; 228 evas_thread_worker = 0;
228 229
229 free(evas_thread_queue_cache); 230 free(evas_thread_queue_cache);
230 evas_thread_queue_cache = NULL; 231 evas_thread_queue_cache = NULL;
231 eina_inarray_flush(&evas_thread_queue); 232 eina_inarray_flush(&evas_thread_queue);
232 233
233 eina_threads_shutdown(); 234 eina_threads_shutdown();
234 235
235 return 0; 236 return 0;
236} 237}