#ifndef AFUN_OBJECT_H #define AFUN_OBJECT_H #include #include #include "aFuntool.h" #include "aFunCoreExport.h" namespace aFuncore { typedef unsigned GcCount; class Inter; class Environment; class AFUN_CORE_EXPORT Object { public: Object(std::string type_, Inter &inter); Object(std::string type_, Environment &env_); virtual ~Object(); Object(const Object &) = delete; Object &operator=(const Object &) = delete; AFUN_INLINE void addReference(); AFUN_INLINE void delReference(); [[nodiscard]] AFUN_INLINE GcCount getReference() const; AFUN_INLINE void setClear(bool clear=false); AFUN_STATIC void checkReachable(std::list &list); AFUN_STATIC void setReachable(std::list &list, std::queue &des, std::queue &del); AFUN_STATIC void destructUnreachable(std::queue &des, Inter &gc_inter); AFUN_STATIC void deleteUnreachable(std::queue &del); AFUN_STATIC void destructAll(std::list &list, Inter &gc_inter); AFUN_STATIC void deleteAll(std::list &list); protected: Environment &env; const std::string type; // 标识 Object 的字符串 std::mutex lock; virtual void destruct(Inter &gc_inter); virtual void linkObject(std::queue &queue); private: bool done_destruct; bool not_clear; // 不清除 bool reachable; // 可达标记 [同时标识已迭代] GcCount reference; // 引用计数 }; }; #include "object.inline.h" #endif //AFUN_OBJECT_H