godot/thirdparty/icu4c/common/unifiedcache.cpp

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
* Copyright (C) 2015, International Business Machines Corporation and
* others. All Rights Reserved.
******************************************************************************
*
* File unifiedcache.cpp
******************************************************************************
*/

#include "unifiedcache.h"

#include <algorithm>      // For std::max()
#include <mutex>

#include "uassert.h"
#include "uhash.h"
#include "ucln_cmn.h"

static icu::UnifiedCache *gCache =;
static std::mutex *gCacheMutex =;
static std::condition_variable *gInProgressValueAddedCond;
static icu::UInitOnce gCacheInitOnce {};

static const int32_t MAX_EVICT_ITERATIONS =;
static const int32_t DEFAULT_MAX_UNUSED =;
static const int32_t DEFAULT_PERCENTAGE_OF_IN_USE =;


U_CDECL_BEGIN
static UBool U_CALLCONV unifiedcache_cleanup() {}
U_CDECL_END


U_NAMESPACE_BEGIN

int32_t U_EXPORT2
ucache_hashKeys(const UHashTok key) {}

UBool U_EXPORT2
ucache_compareKeys(const UHashTok key1, const UHashTok key2) {}

void U_EXPORT2
ucache_deleteKey(void *obj) {}

CacheKeyBase::~CacheKeyBase() {}

static void U_CALLCONV cacheInit(UErrorCode &status) {}

UnifiedCache *UnifiedCache::getInstance(UErrorCode &status) {}

UnifiedCache::UnifiedCache(UErrorCode &status) :{}

void UnifiedCache::setEvictionPolicy(
        int32_t count, int32_t percentageOfInUseItems, UErrorCode &status) {}

int32_t UnifiedCache::unusedCount() const {}

int64_t UnifiedCache::autoEvictedCount() const {}

int32_t UnifiedCache::keyCount() const {}

void UnifiedCache::flush() const {}

void UnifiedCache::handleUnreferencedObject() const {}

#ifdef UNIFIED_CACHE_DEBUG
#include <stdio.h>

void UnifiedCache::dump() {
    UErrorCode status = U_ZERO_ERROR;
    const UnifiedCache *cache = getInstance(status);
    if (U_FAILURE(status)) {
        fprintf(stderr, "Unified Cache: Error fetching cache.\n");
        return;
    }
    cache->dumpContents();
}

void UnifiedCache::dumpContents() const {
    std::lock_guard<std::mutex> lock(*gCacheMutex);
    _dumpContents();
}

// Dumps content of cache.
// On entry, gCacheMutex must be held.
// On exit, cache contents dumped to stderr.
void UnifiedCache::_dumpContents() const {
    int32_t pos = UHASH_FIRST;
    const UHashElement *element = uhash_nextElement(fHashtable, &pos);
    char buffer[256];
    int32_t cnt = 0;
    for (; element != nullptr; element = uhash_nextElement(fHashtable, &pos)) {
        const SharedObject *sharedObject =
                (const SharedObject *) element->value.pointer;
        const CacheKeyBase *key =
                (const CacheKeyBase *) element->key.pointer;
        if (sharedObject->hasHardReferences()) {
            ++cnt;
            fprintf(
                    stderr,
                    "Unified Cache: Key '%s', error %d, value %p, total refcount %d, soft refcount %d\n",
                    key->writeDescription(buffer, 256),
                    key->creationStatus,
                    sharedObject == fNoValue ? nullptr :sharedObject,
                    sharedObject->getRefCount(),
                    sharedObject->getSoftRefCount());
        }
    }
    fprintf(stderr, "Unified Cache: %d out of a total of %d still have hard references\n", cnt, uhash_count(fHashtable));
}
#endif

UnifiedCache::~UnifiedCache() {}

const UHashElement *
UnifiedCache::_nextElement() const {}

UBool UnifiedCache::_flush(UBool all) const {}

int32_t UnifiedCache::_computeCountOfItemsToEvict() const {}

void UnifiedCache::_runEvictionSlice() const {}

void UnifiedCache::_putNew(
        const CacheKeyBase &key,
        const SharedObject *value,
        const UErrorCode creationStatus,
        UErrorCode &status) const {}

void UnifiedCache::_putIfAbsentAndGet(
        const CacheKeyBase &key,
        const SharedObject *&value,
        UErrorCode &status) const {}


UBool UnifiedCache::_poll(
        const CacheKeyBase &key,
        const SharedObject *&value,
        UErrorCode &status) const {}

void UnifiedCache::_get(
        const CacheKeyBase &key,
        const SharedObject *&value,
        const void *creationContext,
        UErrorCode &status) const {}

void UnifiedCache::_registerPrimary(
            const CacheKeyBase *theKey, const SharedObject *value) const {}

void UnifiedCache::_put(
        const UHashElement *element,
        const SharedObject *value,
        const UErrorCode status) const {}

void UnifiedCache::_fetch(
        const UHashElement *element,
        const SharedObject *&value,
        UErrorCode &status) const {}


UBool UnifiedCache::_inProgress(const UHashElement* element) const {}

UBool UnifiedCache::_inProgress(
        const SharedObject* theValue, UErrorCode creationStatus) const {}

UBool UnifiedCache::_isEvictable(const UHashElement *element) const
{}

void UnifiedCache::removeSoftRef(const SharedObject *value) const {}

int32_t UnifiedCache::removeHardRef(const SharedObject *value) const {}

int32_t UnifiedCache::addHardRef(const SharedObject *value) const {}

U_NAMESPACE_END