unsigned long xt_case_cache_get_size(xt_case_cache_t *cache) { assert(cache); unsigned long size; xt_sync_qutex_lock_shared(cache->objects_qutex); size = xt_case_set_get_size(cache->objects); xt_sync_qutex_unlock_shared(cache->objects_qutex); return size; }
void *xt_case_cache_find(xt_case_cache_t *cache, void *object) { assert(cache); assert(object); void *found_object; xt_sync_qutex_lock_shared(cache->objects_qutex); found_object = xt_case_set_find(cache->objects, object); xt_sync_qutex_unlock_shared(cache->objects_qutex); return found_object; }
void *xt_case_cache_find_copy(xt_case_cache_t *cache, void *object) { assert(cache); assert(object); void *object_copy; xt_sync_qutex_lock_shared(cache->objects_qutex); object_copy = xt_case_set_find_copy(cache->objects, object); xt_sync_qutex_unlock_shared(cache->objects_qutex); return object_copy; }
void xt_case_cache_remove_objects(xt_case_cache_t *cache) { assert(cache); void *object; xt_sync_qutex_lock_shared(cache->objects_qutex); { xt_case_set_iterate_start(cache->objects); while ((object = xt_case_set_iterate_next(cache->objects))) { if (cache->remove_condition(object)) { xt_case_set_iterate_remove(cache->objects); } } } xt_sync_qutex_unlock_shared(cache->objects_qutex); }
xt_case_list_t *ta_identity_listen(ta_identity_t *identity, unsigned long next_phrase_id) { assert(identity); unsigned long i; xt_case_list_t *phrases; ta_phrase_t *phrase; ta_phrase_t *phrase_copy; unsigned long phrases_size; phrases = xt_case_list_create(ta_phrase_compare, ta_phrase_copy, ta_phrase_destroy); if (phrases) { xt_sync_qutex_lock_shared(identity->phrases_qutex); phrases_size = xt_case_list_get_size(identity->phrases); check_range_of_next_phrase_id(&next_phrase_id, phrases_size); for (i = next_phrase_id; i < phrases_size; i++) { phrase = xt_case_list_find_at(identity->phrases, i); assert(phrase); phrase_copy = ta_phrase_copy(phrase); if (phrase_copy) { if (!xt_case_list_add_last(phrases, phrase_copy)) { xt_core_log_trace(identity->log, " ta ", "xt_case_list_add_last"); ta_phrase_destroy(phrase_copy); break; } } else { xt_core_log_trace(identity->log, " ta ", "ta_phrase_copy"); break; } } xt_sync_qutex_unlock_shared(identity->phrases_qutex); } else { xt_core_log_trace(identity->log, " ta ", "xt_case_list_create"); } return phrases; }