This commit is contained in:
EmsiaetKadosh
2025-03-06 22:25:43 +08:00
parent 28a836ff5f
commit 7e63aa1217
14 changed files with 7 additions and 6 deletions
+1
View File
@@ -14,6 +14,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/source-charset:utf-8)
add_compile_options(/execution-charset:utf-8)
endif ()
add_compile_options(/Zc:preprocessor)
include(CTest)
enable_testing()
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -30,10 +30,10 @@ class Garbage final : public IGarbage {
public:
explicit Garbage(T* ptr) : IGarbage(ptr) {}
void collect() override { delete static_cast<T*>(ptr); }
void collect() override { delete static_cast<T*>(deallocating(ptr)); }
protected:
void deleteThis() override { delete this; }
void deleteThis() override { delete deallocating(this); }
};
class GarbageCollector {
@@ -76,7 +76,7 @@ public:
/** 只能在gameThread调用 */
template <TypeName T>
void submit(T* ptr) noexcept(false) {
IGarbage* garbage = new Garbage<T>(ptr);
IGarbage* garbage = allocatedFor(new Garbage<T>(ptr));
if (IGarbage* end = submittedEnd) { // 后续添加,可能存在线程竞争
while (end->next) end = end->next; // 理论上不会进入循环,但防止万一
end->next = garbage;
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -170,7 +170,7 @@ bool AnywhereIterator<T, L>::operator==(const AnywhereIteratorEnd& other) const
template <typename T, typename L>
int AnywhereEditableList<T, L>::pushCopy(T* value) noexcept {
T* nv = new T(*value);
T* nv = allocatedFor(new T(*value));
return pushNewed(nv);
}
@@ -191,7 +191,7 @@ int AnywhereEditableList<T, L>::pushThis(T* value) noexcept {
template <typename T, typename L>
int AnywhereEditableList<T, L>::pushNewed(T* value) noexcept {
const int ret = pushThis(value);
if (ret) delete value;
if (ret) delete deallocating(value);
else value->managedByList = true;
return ret;
}
@@ -205,6 +205,6 @@ int AnywhereEditableList<T, L>::pop(T* value) noexcept {
value->list = nullptr;
value->next->prev = value->prev;
value->prev->next = value->next;
if (value->managedByList) delete value;
if (value->managedByList) delete deallocating(value);
Success();
}
BIN
View File
Binary file not shown.