gc.inline.h 910 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef AFUN_GC_INLINE_H
  2. #define AFUN_GC_INLINE_H
  3. #include "gc.h"
  4. namespace aFuncore {
  5. inline GcObjectBase::GcObjectBase() : not_clear{false}, reference{1}, reachable{false} {
  6. }
  7. inline void GcObjectBase::addReference() {
  8. std::unique_lock<std::mutex> mutex{lock};
  9. reference++;
  10. }
  11. inline void GcObjectBase::delReference() {
  12. std::unique_lock<std::mutex> mutex{lock};
  13. reference--;
  14. }
  15. inline GcCount GcObjectBase::getReference() const {
  16. return reference;
  17. }
  18. inline void GcObjectBase::setClear(bool clear) {
  19. not_clear=!clear;
  20. }
  21. inline void GcObjectBase::setReachable(bool is_reference) {
  22. reachable=is_reference;
  23. }
  24. inline size_t GcList::getSize() const {
  25. return queue.size();
  26. }
  27. inline size_t GcList::isEmpty() const {
  28. return queue.empty();
  29. }
  30. }
  31. #endif //AFUN_GC_INLINE_H