コード例 #1
0
ファイル: Logging.cs プロジェクト: mkrufky/Ixian-source
            // Storage thread
            private static void threadLoop()
            {
                LogStatement statement     = new LogStatement();
                bool         message_found = false;

                while (running)
                {
                    TLC.Report();
                    message_found = false;

                    lock (statements)
                    {
                        if (statements.Count() > 0)
                        {
                            LogStatement candidate = statements[0];
                            statement = candidate;
                            statements.Remove(candidate);
                            message_found = true;
                        }
                    }

                    if (message_found)
                    {
                        log_internal(statement.severity, statement.message, statement.threadId, statement.time);
                    }
                    else
                    {
                        // Sleep for 25ms to prevent cpu waste
                        Thread.Sleep(25);
                    }
                    Thread.Yield();
                }
            }
コード例 #2
0
ファイル: Node.cs プロジェクト: AyzeGamingFR/Ixian-DLT
        // Perform periodic cleanup tasks
        private static void performMaintenance()
        {
            while (running)
            {
                TLC.Report();
                // Sleep a while to prevent cpu usage
                Thread.Sleep(10000);

                try
                {
                    TransactionPool.processPendingTransactions();

                    // Cleanup the presence list
                    PresenceList.performCleanup();

                    if (update() == false)
                    {
                        IxianHandler.forceShutdown = true;
                    }
                }
                catch (Exception e)
                {
                    Logging.error("Exception occurent in Node.performMaintenance: " + e);
                }
            }
        }
コード例 #3
0
ファイル: IStorage.cs プロジェクト: requin38/Taams-DLT
            protected virtual void threadLoop()
            {
                QueueStorageMessage active_message = new QueueStorageMessage();

                bool pending_statements = false;

                while (running || pending_statements == true)
                {
                    pending_statements = false;
                    TLC.Report();
                    try
                    {
                        bool message_found = false;

                        lock (queueStatements)
                        {
                            int statements_count = queueStatements.Count();
                            if (statements_count > 0)
                            {
                                if (statements_count > 1)
                                {
                                    pending_statements = true;
                                }
                                QueueStorageMessage candidate = queueStatements[0];
                                active_message = candidate;
                                queueStatements.Remove(candidate);
                                message_found = true;
                            }
                        }

                        if (message_found)
                        {
                            if (active_message.code == QueueStorageCode.insertTransaction)
                            {
                                insertTransactionInternal((Transaction)active_message.data);
                            }
                            else if (active_message.code == QueueStorageCode.insertBlock)
                            {
                                insertBlockInternal((Block)active_message.data);
                            }
                        }
                        else
                        {
                            // Sleep for 10ms to prevent cpu waste
                            Thread.Sleep(10);
                        }
                    }
                    catch (Exception e)
                    {
                        Logging.error("Exception occured in storage thread loop: " + e);
                    }
                    Thread.Yield();
                }
                cleanupCache();
            }
コード例 #4
0
        // Perform periodic cleanup tasks
        private static void performMaintenance()
        {
            while (running)
            {
                TLC.Report();
                // Sleep a while to prevent cpu usage
                Thread.Sleep(1000);

                TransactionPool.processPendingTransactions();

                // Cleanup transaction pool
                TransactionPool.performCleanup();

                // Cleanup the presence list
                PresenceList.performCleanup();
            }
        }
コード例 #5
0
        private void threadLoop()
        {
            while (running)
            {
                TLC.Report();
                if (ConsoleHelpers.verboseConsoleOutput == false)
                {
                    // Clear the screen every 10 seconds to prevent any persisting visual artifacts
                    if (drawCycle > 5)
                    {
                        clearScreen();
                        drawCycle = 0;
                    }
                    else
                    {
                        drawScreen();
                        drawCycle++;
                    }
                }

                Thread.Sleep(2000);
            }
        }
コード例 #6
0
ファイル: IStorage.cs プロジェクト: ProjectIxian/Ixian-DLT
            protected virtual void threadLoop()
            {
                QueueStorageMessage active_message = new QueueStorageMessage();

                bool pending_statements = false;

                while (running || pending_statements == true)
                {
                    bool message_found = false;
                    pending_statements = false;
                    TLC.Report();
                    try
                    {
                        lock (queueStatements)
                        {
                            int statements_count = queueStatements.Count();
                            if (statements_count > 0)
                            {
                                if (statements_count > 1)
                                {
                                    pending_statements = true;
                                }
                                QueueStorageMessage candidate = queueStatements[0];
                                active_message = candidate;
                                message_found  = true;
                            }
                        }

                        if (message_found)
                        {
                            if (active_message.code == QueueStorageCode.insertTransaction)
                            {
                                insertTransactionInternal((Transaction)active_message.data);
                            }
                            else if (active_message.code == QueueStorageCode.insertBlock)
                            {
                                insertBlockInternal((Block)active_message.data);
                            }
                            lock (queueStatements)
                            {
                                queueStatements.RemoveAt(0);
                            }
                        }
                        else
                        {
                            long cur_time = Clock.getTimestamp();
                            if (cur_time - lastCleanupPass > 60)
                            {
                                lastCleanupPass = cur_time;
                                // this is only enabled on Rocks for now
                                if (this is RocksDBStorage)
                                {
                                    cleanupCache();
                                }
                            }
                            // Sleep for 50ms to yield CPU schedule slot
                            Thread.Sleep(50);
                        }
                    }
                    catch (Exception e)
                    {
                        Logging.error("Exception occured in storage thread loop: " + e);
                        if (message_found)
                        {
                            debugDumpCrashObject(active_message);
                            active_message.retryCount += 1;
                            if (active_message.retryCount > 10)
                            {
                                lock (queueStatements)
                                {
                                    queueStatements.RemoveAt(0);
                                }
                                Logging.error("Too many retries, aborting...");
                                shutdown();
                                throw new Exception("Too many storage retries. Aborting storage thread.");
                            }
                        }
                    }
                    Thread.Yield();
                }
                shutdown();
                Logging.info("Storage stopped.");
            }