Example #1
0
        //internal bool IfWriteThread()
        //{
        //    return (_masterTrie.NestedTablesCoordinator.ModificationThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId);
        //}


        internal NestedTable GetTable <TKey>(TKey key, uint tableIndex, bool insertIsAllowed)
        {
            byte[]   btKey = DataTypesConvertor.ConvertKey <TKey>(key);
            LTrieRow row   = null;

            if (insertIsAllowed)        //Insert of table is allowed by calls generation
            {
                row = table.GetKey(ref btKey, null);
                return(table.GetTable(row, ref btKey, tableIndex, this._masterTrie, true, false));
            }

            //Only selects are allowed

            if (_masterTrie.NestedTablesCoordinator.ModificationThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId)
            {
                //This thread must NOT use cache
                row = table.GetKey(ref btKey, null);
                return(table.GetTable(row, ref btKey, tableIndex, this._masterTrie, false, false));
            }
            else
            {
                LTrieRootNode readRootNode = new LTrieRootNode(table);
                row = table.GetKey(ref btKey, readRootNode);

                return(table.GetTable(row, ref btKey, tableIndex, this._masterTrie, false, true));
            }
        }