Exemple #1
0
static inline RingBufferEntry*
initEntry(RingBufferType t, uint64_t funcId, int offset) {
    RingBufferEntry* rb = allocEntry(t);
    rb->m_funcId = funcId;
    rb->m_offset = offset;
    return rb;
}
Exemple #2
0
static inline RingBufferEntry*
initEntry(RingBufferType t, uint64_t sk, uint64_t data) {
  RingBufferEntry* rb = allocEntry(t);
  rb->m_sk = sk;
  rb->m_data = data;
  return rb;
}
TickCacheEntry * TickCache::addCacheEntry()
{
   // Add a new entry, creating head if needed
   if (!mTickCacheHead)
   {
      mTickCacheHead = allocHead();
      mTickCacheHead->newest = mTickCacheHead->oldest = mTickCacheHead->next = NULL;
      mTickCacheHead->numEntry = 0;
   }
   if (!mTickCacheHead->newest)
   {
      mTickCacheHead->newest = mTickCacheHead->oldest = allocEntry();
   }
   else
   {
      mTickCacheHead->newest->next = allocEntry();
      mTickCacheHead->newest = mTickCacheHead->newest->next;
   }
   mTickCacheHead->newest->next = NULL;
   mTickCacheHead->newest->move = NULL;
   mTickCacheHead->numEntry++;
   return mTickCacheHead->newest;
}
Exemple #4
0
	void StringID::construct(T const& name)
	{
		assert(StringIDUtil<T>::size(name) <= STRING_SIZE);

		UINT32 hash = calcHash(name) & (sizeof(mStringHashTable) / sizeof(mStringHashTable[0]) - 1);
		InternalData* existingEntry = mStringHashTable[hash];
		
		while (existingEntry != nullptr)
		{
			if (StringIDUtil<T>::compare(name, existingEntry->chars))
			{
				mData = existingEntry;
				return;
			}

			existingEntry = existingEntry->next;
		}

		ScopedSpinLock lock(mSync);

		// Search for the value again in case other thread just added it
		existingEntry = mStringHashTable[hash];
		InternalData* lastEntry = nullptr;
		while (existingEntry != nullptr)
		{
			if (StringIDUtil<T>::compare(name, existingEntry->chars))
			{
				mData = existingEntry;
				return;
			}

			lastEntry = existingEntry;
			existingEntry = existingEntry->next;
		}

		mData = allocEntry();
		StringIDUtil<T>::copy(name, mData->chars);

		if (lastEntry == nullptr)
			mStringHashTable[hash] = mData;
		else
			lastEntry->next = mData;
	}
Exemple #5
0
static inline RingBufferEntry*
initEntry(RingBufferType t) {
    RingBufferEntry* rb = allocEntry(t);
    return rb;
}
Exemple #6
0
StringTableEntry stringtable_insert(const char *str)
{
    unsigned long      hash_result;
    stringTableEntry_t *walk  = NULL;
    StringTableEntry   result = NULL;
    int                bucket;

    // Hash the string.
    hash_result = hash(str);

    // Determine the hash table bucket.
    bucket = hash_result % csmTableSize;

    // TODO: Make this a readwrite lock, since most of the time we are just
    // traversing the stringtable to find existing data, not inserting.
    loom_mutex_lock(gTableMutex);

    // Walk the chain, if any.
    walk = gTable[bucket];

    // Empty bucket, easy case!
    if (!walk)
    {
        gTable[bucket] = allocEntry(str);
        assert(gTable[bucket]->string);
        result = gTable[bucket]->string;
        loom_mutex_unlock(gTableMutex);

        return result;
    }

    while (walk)
    {
        // Is it a match?
        if (strcmp(walk->string, str) == 0)
        {
            assert(walk->string);
            result = (StringTableEntry)walk->string;
            loom_mutex_unlock(gTableMutex);

            return result;
        }

        // Another one to check?
        if (walk->next != NULL)
        {
            walk = walk->next;
            continue;
        }

        break;
    }

    // No match. Chain 'er on.
    walk->next = allocEntry(str);
    assert(walk->next->string);
    result = walk->next->string;
    loom_mutex_unlock(gTableMutex);

    return result;
}