Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Util MP - Hash Table.h
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
#if !defined(TGS_COMMON_UTIL_MP_HASH_TABLE_H)
#define TGS_COMMON_UTIL_MP_HASH_TABLE_H
#pragma once


/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Types                                                                                                                                                          */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgTYPE_STRUCT(STg2_UTM_Hash_Node,)
{
    TgUINTXX                                    m_uiNext;
    TgUINTXX                                    m_uiHash;
    TgUINT64                                    m_uiVal;
};

TgTYPE_STRUCT(STg2_UTM_AM_HT,)
{
    STg2_UTM_AM_RW_ISO                          m_sLock;

    PP_STg2_UTM_Hash_Node                       m_psHash_List;
    P_STg2_UTM_Hash_Node                        m_psNode_List;
    TgUINTXX                                    m_uiFree_Node;
    TgUINTXX                                    m_nuiEntries;
    TgUINTXX                                    m_nuiNode_Commit;
    TgUINTXX                                    m_nuiNode_Virtual;
#if 0 != (112 % TgCOMPILE_CACHE_LINE_SIZE)
    TgUINT08                                    m_uiPad0[TgCOMPILE_CACHE_LINE_SIZE - (112 % TgCOMPILE_CACHE_LINE_SIZE)];
#endif
};


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

                                            /* 2: Number of entries in the first level of the hash table */
                                            /* 3: Max number of nodes to be supported */
TgEXTN TgRESULT                             tgCM_UTM_HT_Init_Virtual( P_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINTXX );

                                            /* 2: Number of entries in the first level of the hash table */
                                            /* 3: Number of bytes in the buffer */
                                            /* 4: A buffer for the total number of nodes or nullptr for a reserve | commit model */
TgEXTN TgRESULT                             tgCM_UTM_HT_Init_Fixed( PCU_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINTXX, P_TgVOID );

TgINLINE TgVOID                             tgCM_UTM_HT_Free( PCU_STg2_UTM_AM_HT );

TgINLINE TgVOID                             tgCM_UTM_HT_Clear( PCU_STg2_UTM_AM_HT );

                                            /* 1: Output value associated with hash */
                                            /* 2: Hash */
                                            /* 3: Hash Table */
TgINLINE TgRESULT                           tgCM_UTM_HT_Find_Yield( P_TgUINTPTR, C_TgUINTXX, PCU_STg2_UTM_AM_HT );
TgINLINE TgRESULT                           tgCM_UTM_HT_Find_Spin( P_TgUINTPTR, C_TgUINTXX, PCU_STg2_UTM_AM_HT );
TgINLINE TgRESULT                           tgCM_UTM_HT_Find( P_TgUINTPTR, C_TgUINTXX, PCU_STg2_UTM_AM_HT );

TgINLINE TgRESULT                           tgCM_UTM_HT_Insert_Yield( PCU_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINT64 );
TgINLINE TgRESULT                           tgCM_UTM_HT_Insert_Spin( PCU_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINT64 );
TgINLINE TgRESULT                           tgCM_UTM_HT_Insert( PCU_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINT64 );

TgINLINE TgRESULT                           tgCM_UTM_HT_Update_Yield( PCU_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINT64 );
TgINLINE TgRESULT                           tgCM_UTM_HT_Update_Spin( PCU_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINT64 );
TgINLINE TgRESULT                           tgCM_UTM_HT_Update( PCU_STg2_UTM_AM_HT, C_TgUINTXX, C_TgUINT64 );

TgINLINE TgRESULT                           tgCM_UTM_HT_Remove_Yield( PCU_STg2_UTM_AM_HT, C_TgUINTXX );
TgINLINE TgRESULT                           tgCM_UTM_HT_Remove_Spin( PCU_STg2_UTM_AM_HT, C_TgUINTXX );
TgINLINE TgRESULT                           tgCM_UTM_HT_Remove( PCU_STg2_UTM_AM_HT, C_TgUINTXX );


/* ====================================================================================================================================================================== */
#endif