forked from enlightenment/efl
eet: use Eina_Spinlock instead of Eina_Lock for Eet_Dictionary.
This commit is contained in:
parent
435caae51a
commit
b9d8a7af3a
|
@ -1,8 +1,8 @@
|
||||||
2013-10-11 Cedric Bail
|
2013-10-11 Cedric Bail
|
||||||
|
|
||||||
* Eina: add Eina_Spinlock API,
|
* Eina: add Eina_Spinlock API,
|
||||||
use Eina_Spinlock in Eina_Log,
|
use Eina_Spinlock in Eina_Log, replace Eina_Lock by Eina_Spinlock in Eina_Stringshare.
|
||||||
replace Eina_Lock by Eina_Spinlock in Eina_Stringshare.
|
* Eet: replace Eina_Lock by Eina_Spinlock in Eet_Dictionnary.
|
||||||
|
|
||||||
2013-10-10 Carsten Haitzler (The Rasterman)
|
2013-10-10 Carsten Haitzler (The Rasterman)
|
||||||
|
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -202,6 +202,7 @@ Improvements:
|
||||||
* Eet:
|
* Eet:
|
||||||
- Display more information with eet -l -v.
|
- Display more information with eet -l -v.
|
||||||
- Force thread to always run during eet_cache_concurrency test.
|
- Force thread to always run during eet_cache_concurrency test.
|
||||||
|
- Use Eina_Spinlock for locking dictionnary instead of Eina_Lock.
|
||||||
* Evas:
|
* Evas:
|
||||||
- Reduced number of enqueued font commands when rendering textgrid objects
|
- Reduced number of enqueued font commands when rendering textgrid objects
|
||||||
- Use Eina_File in webp, gif, tiff, png and eet loader
|
- Use Eina_File in webp, gif, tiff, png and eet loader
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct _Eet_Dictionary
|
||||||
unsigned char *all_allocated;
|
unsigned char *all_allocated;
|
||||||
|
|
||||||
Eina_Hash *converts;
|
Eina_Hash *converts;
|
||||||
Eina_Lock mutex;
|
Eina_Spinlock mutex;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
|
@ -21,7 +21,7 @@ eet_dictionary_add(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memset(new->hash, -1, sizeof (int) * 256);
|
memset(new->hash, -1, sizeof (int) * 256);
|
||||||
eina_lock_new(&new->mutex);
|
eina_spinlock_new(&new->mutex);
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ eet_dictionary_free(Eet_Dictionary *ed)
|
||||||
|
|
||||||
if (!ed) return;
|
if (!ed) return;
|
||||||
|
|
||||||
eina_lock_free(&ed->mutex);
|
eina_spinlock_free(&ed->mutex);
|
||||||
|
|
||||||
for (i = 0; i < ed->count; ++i)
|
for (i = 0; i < ed->count; ++i)
|
||||||
if (ed->all_allocated[i >> 8] & (1 << (i & 0x7)))
|
if (ed->all_allocated[i >> 8] & (1 << (i & 0x7)))
|
||||||
|
@ -108,7 +108,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
hash = _eet_hash_gen(string, 8);
|
hash = _eet_hash_gen(string, 8);
|
||||||
len = strlen(string) + 1;
|
len = strlen(string) + 1;
|
||||||
|
|
||||||
eina_lock_take(&ed->mutex);
|
eina_spinlock_take(&ed->mutex);
|
||||||
|
|
||||||
idx = _eet_dictionary_lookup(ed, string, len, hash, &pidx);
|
idx = _eet_dictionary_lookup(ed, string, len, hash, &pidx);
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
((ed->all[idx].str == string) ||
|
((ed->all[idx].str == string) ||
|
||||||
(!strcmp(ed->all[idx].str, string))))
|
(!strcmp(ed->all[idx].str, string))))
|
||||||
{
|
{
|
||||||
eina_lock_release(&ed->mutex);
|
eina_spinlock_release(&ed->mutex);
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,11 +174,11 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = ed->count++;
|
cnt = ed->count++;
|
||||||
eina_lock_release(&ed->mutex);
|
eina_spinlock_release(&ed->mutex);
|
||||||
return cnt;
|
return cnt;
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
eina_lock_release(&ed->mutex);
|
eina_spinlock_release(&ed->mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,12 +192,12 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed,
|
||||||
|
|
||||||
if (idx < 0) goto done;
|
if (idx < 0) goto done;
|
||||||
|
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
if (idx < ed->count)
|
if (idx < ed->count)
|
||||||
length = ed->all[idx].len;
|
length = ed->all[idx].len;
|
||||||
|
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return length;
|
return length;
|
||||||
|
@ -219,12 +219,12 @@ eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
|
||||||
|
|
||||||
if (idx < 0) goto done;
|
if (idx < 0) goto done;
|
||||||
|
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
if (idx < ed->count)
|
if (idx < ed->count)
|
||||||
hash = ed->all_hash[idx];
|
hash = ed->all_hash[idx];
|
||||||
|
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return hash;
|
return hash;
|
||||||
|
@ -240,7 +240,7 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed,
|
||||||
|
|
||||||
if (idx < 0) goto done;
|
if (idx < 0) goto done;
|
||||||
|
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
if (idx < ed->count)
|
if (idx < ed->count)
|
||||||
{
|
{
|
||||||
|
@ -255,7 +255,7 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed,
|
||||||
s = ed->all[idx].str;
|
s = ed->all[idx].str;
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return s;
|
return s;
|
||||||
|
@ -333,14 +333,14 @@ _eet_dictionary_test(const Eet_Dictionary *ed,
|
||||||
|
|
||||||
if (idx < 0) goto done;
|
if (idx < 0) goto done;
|
||||||
|
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
if (!(idx < ed->count)) goto unlock_done;
|
if (!(idx < ed->count)) goto unlock_done;
|
||||||
|
|
||||||
limit = EINA_TRUE;
|
limit = EINA_TRUE;
|
||||||
|
|
||||||
unlock_done:
|
unlock_done:
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return limit;
|
return limit;
|
||||||
|
@ -353,7 +353,7 @@ eet_dictionary_convert_get(const Eet_Dictionary *ed,
|
||||||
{
|
{
|
||||||
Eet_Convert *result;
|
Eet_Convert *result;
|
||||||
|
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
*str = ed->all[idx].str;
|
*str = ed->all[idx].str;
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ eet_dictionary_convert_get(const Eet_Dictionary *ed,
|
||||||
eina_hash_add(ed->converts, &idx, result);
|
eina_hash_add(ed->converts, &idx, result);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed,
|
||||||
|
|
||||||
if (!(convert->type & EET_D_FLOAT))
|
if (!(convert->type & EET_D_FLOAT))
|
||||||
{
|
{
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
if (!_eet_dictionary_string_get_float_cache(str, ed->all[idx].len,
|
if (!_eet_dictionary_string_get_float_cache(str, ed->all[idx].len,
|
||||||
&convert->f))
|
&convert->f))
|
||||||
{
|
{
|
||||||
|
@ -404,13 +404,13 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed,
|
||||||
if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
|
if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
|
||||||
&exponent) == EINA_FALSE)
|
&exponent) == EINA_FALSE)
|
||||||
{
|
{
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert->f = ldexpf((float)mantisse, exponent);
|
convert->f = ldexpf((float)mantisse, exponent);
|
||||||
}
|
}
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
convert->type |= EET_D_FLOAT;
|
convert->type |= EET_D_FLOAT;
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed,
|
||||||
|
|
||||||
if (!(convert->type & EET_D_DOUBLE))
|
if (!(convert->type & EET_D_DOUBLE))
|
||||||
{
|
{
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
if (!_eet_dictionary_string_get_double_cache(str, ed->all[idx].len,
|
if (!_eet_dictionary_string_get_double_cache(str, ed->all[idx].len,
|
||||||
&convert->d))
|
&convert->d))
|
||||||
|
@ -446,13 +446,13 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed,
|
||||||
if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
|
if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
|
||||||
&exponent) == EINA_FALSE)
|
&exponent) == EINA_FALSE)
|
||||||
{
|
{
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert->d = ldexp((double)mantisse, exponent);
|
convert->d = ldexp((double)mantisse, exponent);
|
||||||
}
|
}
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
convert->type |= EET_D_DOUBLE;
|
convert->type |= EET_D_DOUBLE;
|
||||||
}
|
}
|
||||||
|
@ -479,13 +479,13 @@ eet_dictionary_string_get_fp(const Eet_Dictionary *ed,
|
||||||
{
|
{
|
||||||
Eina_F32p32 fp;
|
Eina_F32p32 fp;
|
||||||
|
|
||||||
eina_lock_take((Eina_Lock*) &ed->mutex);
|
eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
|
||||||
if (!eina_convert_atofp(str, ed->all[idx].len, &fp))
|
if (!eina_convert_atofp(str, ed->all[idx].len, &fp))
|
||||||
{
|
{
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
eina_lock_release((Eina_Lock*) &ed->mutex);
|
eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
|
||||||
|
|
||||||
convert->fp = fp;
|
convert->fp = fp;
|
||||||
convert->type |= EET_D_FIXED_POINT;
|
convert->type |= EET_D_FIXED_POINT;
|
||||||
|
@ -505,7 +505,7 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
|
||||||
if ((!ed) || (!string))
|
if ((!ed) || (!string))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
eina_lock_take(&ed->mutex);
|
eina_spinlock_take(&ed->mutex);
|
||||||
|
|
||||||
if ((ed->start <= string) && (string < ed->end))
|
if ((ed->start <= string) && (string < ed->end))
|
||||||
res = 1;
|
res = 1;
|
||||||
|
@ -520,7 +520,7 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_lock_release(&ed->mutex);
|
eina_spinlock_release(&ed->mutex);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue