📄 gcimpl.hpp
字号:
//// This file is part of the "More for C++" library//// Copyright (c) 1999-2003 by Thorsten Goertz (thorsten@morefor.org)//// The "More for C++" library is free software; you can redistribute it and/or// modify it under the terms of the license that comes with this package.//// Read "license.txt" for more details.//// THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES// OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.////////////////////////////////////////////////////////////////////////////////#ifndef GCIMPL_HPP#define GCIMPL_HPP////////////////////////////////////////////////////////////////////////////////#include <more/core/finalizable.hpp>#include <more/core/heapmanager.hpp>#include <more/os/mutex.hpp>#include <more/os/thread.hpp>#include "aligningheapmanager.hpp"#include "defaultheapmanager.hpp"#include "handle.hpp"#include "objectstack.hpp"////////////////////////////////////////////////////////////////////////////////namespace more{ namespace core { class GCImpl { public: static void init( HeapManager* ); static void shutDown( ); static void* createObject( size_t nSizeOfObject, bool bMayBeNode ); static bool isRootPointer( void** ppObject ); static Handle* resolveObject( void* ); static void initPointer( void**&, void*, Finalizable* ); static void assignObject( void**&, void*, Finalizable*, bool bIsRootPointer ); static void forgetObject( void**&, bool bIsRootPointer ); static void forgetUnassignedObject( void* ); static void startCollectorThread( ); static void stopCollectorThread( ); static void declareObjectsTare( ); static size_t getNoOfObjects( ); static void collectObjects( ); private: void addObject( Handle* ); Handle* getLastObject( ) const; Handle* getPreviousObject( Handle* ) const; void removeObject( Handle* pObject, Handle* pNextObject ); void markObjects( ); void unmarkRootObjectTree( ); void unmarkChildObjects( Handle* pHandle ); void finalizeMarkedObjects( ); void sweepMarkedObjects( ); void setNodeFlag( Handle*, bool bObjectMayBeNode ); bool objectMayBeNode( Handle* ) const; void setGarbageFlag( Handle*, bool bGarbage ); bool objectIsGarbage( Handle* pHandle ) const; static Handle nilHandle; static DefaultHeapManager defaultHeapManager; static AligningHeapManager aligningHeapManager; HeapManager* m_pHeapManager; Handle* m_pLastObject; size_t m_nNoOfObjects; size_t m_nNoOfTareObjects; bool m_bCollecting; ObjectStack* m_pMarkStack; p<more::os::Mutex>* m_ppMutex; p<more::os::Thread>* m_ppCollectorThread; }; }}////////////////////////////////////////////////////////////////////////////////#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -