xt_core_bool_t ta_identity_talk(ta_identity_t *identity, ta_phrase_t *phrase) { assert(identity); assert(phrase); xt_core_bool_t success; xt_core_bool_t zap; if (xt_case_list_get_size(identity->phrases) >= MAX_PHRASES_SIZE) { zap = xt_core_bool_true; } else { zap = xt_core_bool_false; } xt_sync_qutex_lock_exclusive(identity->phrases_qutex); if (zap) { xt_case_list_clear(identity->phrases); } ta_phrase_set_id(phrase, xt_case_list_get_size(identity->phrases)); if (xt_case_list_add_last(identity->phrases, phrase)) { xt_sync_qutex_unlock_exclusive(identity->phrases_qutex); success = xt_core_bool_true; } else { xt_sync_qutex_unlock_exclusive(identity->phrases_qutex); xt_core_log_enter(identity->log, " ta ", "xt_case_list_add_last"); success = xt_core_bool_false; } return success; }
xt_core_bool_t xt_case_cache_add(xt_case_cache_t *cache, void *object) { assert(cache); assert(object); xt_core_bool_t success; xt_sync_qutex_lock_exclusive(cache->objects_qutex); success = xt_case_set_add(cache->objects, object); xt_sync_qutex_unlock_exclusive(cache->objects_qutex); if (!success) { xt_core_trace("x_case_set_add"); } return success; }
void xt_case_cache_clear(xt_case_cache_t *cache) { xt_sync_qutex_lock_exclusive(cache->objects_qutex); xt_case_set_clear(cache->objects); xt_sync_qutex_unlock_exclusive(cache->objects_qutex); }