summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-10-10 17:27:41 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-10-11 11:08:17 +0900
commitb9d8a7af3ac164f47f62329c278d1cf09d9b1346 (patch)
tree0cd4586f73acee35fd8e166a863f1b19fcfffcf2
parent435caae51a3ee01c8b55a4c1b944b5537bf20aef (diff)
eet: use Eina_Spinlock instead of Eina_Lock for Eet_Dictionary.
-rw-r--r--ChangeLog4
-rw-r--r--NEWS1
-rw-r--r--src/lib/eet/Eet_private.h2
-rw-r--r--src/lib/eet/eet_dictionary.c54
4 files changed, 31 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index fcedcf49aa..892a7a8415 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,8 @@
12013-10-11 Cedric Bail 12013-10-11 Cedric Bail
2 2
3 * Eina: add Eina_Spinlock API, 3 * Eina: add Eina_Spinlock API,
4 use Eina_Spinlock in Eina_Log, 4 use Eina_Spinlock in Eina_Log, replace Eina_Lock by Eina_Spinlock in Eina_Stringshare.
5 replace Eina_Lock by Eina_Spinlock in Eina_Stringshare. 5 * Eet: replace Eina_Lock by Eina_Spinlock in Eet_Dictionnary.
6 6
72013-10-10 Carsten Haitzler (The Rasterman) 72013-10-10 Carsten Haitzler (The Rasterman)
8 8
diff --git a/NEWS b/NEWS
index 509d17c2c7..00c4dbda5b 100644
--- a/NEWS
+++ b/NEWS
@@ -202,6 +202,7 @@ Improvements:
202 * Eet: 202 * Eet:
203 - Display more information with eet -l -v. 203 - Display more information with eet -l -v.
204 - Force thread to always run during eet_cache_concurrency test. 204 - Force thread to always run during eet_cache_concurrency test.
205 - Use Eina_Spinlock for locking dictionnary instead of Eina_Lock.
205 * Evas: 206 * Evas:
206 - Reduced number of enqueued font commands when rendering textgrid objects 207 - Reduced number of enqueued font commands when rendering textgrid objects
207 - Use Eina_File in webp, gif, tiff, png and eet loader 208 - Use Eina_File in webp, gif, tiff, png and eet loader
diff --git a/src/lib/eet/Eet_private.h b/src/lib/eet/Eet_private.h
index af4f75e109..5d57c0172a 100644
--- a/src/lib/eet/Eet_private.h
+++ b/src/lib/eet/Eet_private.h
@@ -40,7 +40,7 @@ struct _Eet_Dictionary
40 unsigned char *all_allocated; 40 unsigned char *all_allocated;
41 41
42 Eina_Hash *converts; 42 Eina_Hash *converts;
43 Eina_Lock mutex; 43 Eina_Spinlock mutex;
44 44
45 int size; 45 int size;
46 int offset; 46 int offset;
diff --git a/src/lib/eet/eet_dictionary.c b/src/lib/eet/eet_dictionary.c
index b003616787..d3466508ad 100644
--- a/src/lib/eet/eet_dictionary.c
+++ b/src/lib/eet/eet_dictionary.c
@@ -21,7 +21,7 @@ eet_dictionary_add(void)
21 return NULL; 21 return NULL;
22 22
23 memset(new->hash, -1, sizeof (int) * 256); 23 memset(new->hash, -1, sizeof (int) * 256);
24 eina_lock_new(&new->mutex); 24 eina_spinlock_new(&new->mutex);
25 25
26 return new; 26 return new;
27} 27}
@@ -33,7 +33,7 @@ eet_dictionary_free(Eet_Dictionary *ed)
33 33
34 if (!ed) return; 34 if (!ed) return;
35 35
36 eina_lock_free(&ed->mutex); 36 eina_spinlock_free(&ed->mutex);
37 37
38 for (i = 0; i < ed->count; ++i) 38 for (i = 0; i < ed->count; ++i)
39 if (ed->all_allocated[i >> 8] & (1 << (i & 0x7))) 39 if (ed->all_allocated[i >> 8] & (1 << (i & 0x7)))
@@ -108,7 +108,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
108 hash = _eet_hash_gen(string, 8); 108 hash = _eet_hash_gen(string, 8);
109 len = strlen(string) + 1; 109 len = strlen(string) + 1;
110 110
111 eina_lock_take(&ed->mutex); 111 eina_spinlock_take(&ed->mutex);
112 112
113 idx = _eet_dictionary_lookup(ed, string, len, hash, &pidx); 113 idx = _eet_dictionary_lookup(ed, string, len, hash, &pidx);
114 114
@@ -118,7 +118,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
118 ((ed->all[idx].str == string) || 118 ((ed->all[idx].str == string) ||
119 (!strcmp(ed->all[idx].str, string)))) 119 (!strcmp(ed->all[idx].str, string))))
120 { 120 {
121 eina_lock_release(&ed->mutex); 121 eina_spinlock_release(&ed->mutex);
122 return idx; 122 return idx;
123 } 123 }
124 } 124 }
@@ -174,11 +174,11 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
174 } 174 }
175 175
176 cnt = ed->count++; 176 cnt = ed->count++;
177 eina_lock_release(&ed->mutex); 177 eina_spinlock_release(&ed->mutex);
178 return cnt; 178 return cnt;
179 179
180 on_error: 180 on_error:
181 eina_lock_release(&ed->mutex); 181 eina_spinlock_release(&ed->mutex);
182 return -1; 182 return -1;
183} 183}
184 184
@@ -192,12 +192,12 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed,
192 192
193 if (idx < 0) goto done; 193 if (idx < 0) goto done;
194 194
195 eina_lock_take((Eina_Lock*) &ed->mutex); 195 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
196 196
197 if (idx < ed->count) 197 if (idx < ed->count)
198 length = ed->all[idx].len; 198 length = ed->all[idx].len;
199 199
200 eina_lock_release((Eina_Lock*) &ed->mutex); 200 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
201 201
202 done: 202 done:
203 return length; 203 return length;
@@ -219,12 +219,12 @@ eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
219 219
220 if (idx < 0) goto done; 220 if (idx < 0) goto done;
221 221
222 eina_lock_take((Eina_Lock*) &ed->mutex); 222 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
223 223
224 if (idx < ed->count) 224 if (idx < ed->count)
225 hash = ed->all_hash[idx]; 225 hash = ed->all_hash[idx];
226 226
227 eina_lock_release((Eina_Lock*) &ed->mutex); 227 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
228 228
229 done: 229 done:
230 return hash; 230 return hash;
@@ -240,7 +240,7 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed,
240 240
241 if (idx < 0) goto done; 241 if (idx < 0) goto done;
242 242
243 eina_lock_take((Eina_Lock*) &ed->mutex); 243 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
244 244
245 if (idx < ed->count) 245 if (idx < ed->count)
246 { 246 {
@@ -255,7 +255,7 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed,
255 s = ed->all[idx].str; 255 s = ed->all[idx].str;
256 } 256 }
257 257
258 eina_lock_release((Eina_Lock*) &ed->mutex); 258 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
259 259
260 done: 260 done:
261 return s; 261 return s;
@@ -333,14 +333,14 @@ _eet_dictionary_test(const Eet_Dictionary *ed,
333 333
334 if (idx < 0) goto done; 334 if (idx < 0) goto done;
335 335
336 eina_lock_take((Eina_Lock*) &ed->mutex); 336 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
337 337
338 if (!(idx < ed->count)) goto unlock_done; 338 if (!(idx < ed->count)) goto unlock_done;
339 339
340 limit = EINA_TRUE; 340 limit = EINA_TRUE;
341 341
342 unlock_done: 342 unlock_done:
343 eina_lock_release((Eina_Lock*) &ed->mutex); 343 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
344 344
345 done: 345 done:
346 return limit; 346 return limit;
@@ -353,7 +353,7 @@ eet_dictionary_convert_get(const Eet_Dictionary *ed,
353{ 353{
354 Eet_Convert *result; 354 Eet_Convert *result;
355 355
356 eina_lock_take((Eina_Lock*) &ed->mutex); 356 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
357 357
358 *str = ed->all[idx].str; 358 *str = ed->all[idx].str;
359 359
@@ -373,7 +373,7 @@ eet_dictionary_convert_get(const Eet_Dictionary *ed,
373 eina_hash_add(ed->converts, &idx, result); 373 eina_hash_add(ed->converts, &idx, result);
374 374
375 done: 375 done:
376 eina_lock_release((Eina_Lock*) &ed->mutex); 376 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
377 377
378 return result; 378 return result;
379} 379}
@@ -394,7 +394,7 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed,
394 394
395 if (!(convert->type & EET_D_FLOAT)) 395 if (!(convert->type & EET_D_FLOAT))
396 { 396 {
397 eina_lock_take((Eina_Lock*) &ed->mutex); 397 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
398 if (!_eet_dictionary_string_get_float_cache(str, ed->all[idx].len, 398 if (!_eet_dictionary_string_get_float_cache(str, ed->all[idx].len,
399 &convert->f)) 399 &convert->f))
400 { 400 {
@@ -404,13 +404,13 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed,
404 if (eina_convert_atod(str, ed->all[idx].len, &mantisse, 404 if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
405 &exponent) == EINA_FALSE) 405 &exponent) == EINA_FALSE)
406 { 406 {
407 eina_lock_release((Eina_Lock*) &ed->mutex); 407 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
408 return EINA_FALSE; 408 return EINA_FALSE;
409 } 409 }
410 410
411 convert->f = ldexpf((float)mantisse, exponent); 411 convert->f = ldexpf((float)mantisse, exponent);
412 } 412 }
413 eina_lock_release((Eina_Lock*) &ed->mutex); 413 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
414 414
415 convert->type |= EET_D_FLOAT; 415 convert->type |= EET_D_FLOAT;
416 } 416 }
@@ -435,7 +435,7 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed,
435 435
436 if (!(convert->type & EET_D_DOUBLE)) 436 if (!(convert->type & EET_D_DOUBLE))
437 { 437 {
438 eina_lock_take((Eina_Lock*) &ed->mutex); 438 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
439 439
440 if (!_eet_dictionary_string_get_double_cache(str, ed->all[idx].len, 440 if (!_eet_dictionary_string_get_double_cache(str, ed->all[idx].len,
441 &convert->d)) 441 &convert->d))
@@ -446,13 +446,13 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed,
446 if (eina_convert_atod(str, ed->all[idx].len, &mantisse, 446 if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
447 &exponent) == EINA_FALSE) 447 &exponent) == EINA_FALSE)
448 { 448 {
449 eina_lock_release((Eina_Lock*) &ed->mutex); 449 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
450 return EINA_FALSE; 450 return EINA_FALSE;
451 } 451 }
452 452
453 convert->d = ldexp((double)mantisse, exponent); 453 convert->d = ldexp((double)mantisse, exponent);
454 } 454 }
455 eina_lock_release((Eina_Lock*) &ed->mutex); 455 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
456 456
457 convert->type |= EET_D_DOUBLE; 457 convert->type |= EET_D_DOUBLE;
458 } 458 }
@@ -479,13 +479,13 @@ eet_dictionary_string_get_fp(const Eet_Dictionary *ed,
479 { 479 {
480 Eina_F32p32 fp; 480 Eina_F32p32 fp;
481 481
482 eina_lock_take((Eina_Lock*) &ed->mutex); 482 eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
483 if (!eina_convert_atofp(str, ed->all[idx].len, &fp)) 483 if (!eina_convert_atofp(str, ed->all[idx].len, &fp))
484 { 484 {
485 eina_lock_release((Eina_Lock*) &ed->mutex); 485 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
486 return EINA_FALSE; 486 return EINA_FALSE;
487 } 487 }
488 eina_lock_release((Eina_Lock*) &ed->mutex); 488 eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
489 489
490 convert->fp = fp; 490 convert->fp = fp;
491 convert->type |= EET_D_FIXED_POINT; 491 convert->type |= EET_D_FIXED_POINT;
@@ -505,7 +505,7 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
505 if ((!ed) || (!string)) 505 if ((!ed) || (!string))
506 return 0; 506 return 0;
507 507
508 eina_lock_take(&ed->mutex); 508 eina_spinlock_take(&ed->mutex);
509 509
510 if ((ed->start <= string) && (string < ed->end)) 510 if ((ed->start <= string) && (string < ed->end))
511 res = 1; 511 res = 1;
@@ -520,7 +520,7 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
520 } 520 }
521 } 521 }
522 522
523 eina_lock_release(&ed->mutex); 523 eina_spinlock_release(&ed->mutex);
524 524
525 return res; 525 return res;
526} 526}