Huggle
build:^490^dce1e5c
|
Base for all items that are supposed to be collected by garbage collector. More...
#include <collectable.hpp>
Public Member Functions | |
unsigned long | CollectableID () |
CollectableID. More... | |
QString | DebugHgc () |
DebugHgc. More... | |
bool | IsLocked () |
bool | IsManaged () |
IsManaged Managed class is deleted by GC and must not be deleted by hand. More... | |
void | Lock () |
Lock this object so that other threads can't change consumers or modify its properties. | |
void | RegisterConsumer (const int consumer) |
Registers a consumer. More... | |
void | RegisterConsumer (const QString consumer) |
Registers a consumer. More... | |
virtual bool | SafeDelete () |
Use this if you are not sure if you can delete this object in this moment. | |
void | Unlock () |
Unlock this object for deletion by other threads. | |
void | UnregisterConsumer (const int consumer) |
This function will remove a string which prevent the object from being removed. More... | |
void | UnregisterConsumer (const QString consumer) |
This function will remove a string which prevent the object from being removed. More... | |
Private Member Functions | |
void | SetManaged () |
Static Private Member Functions | |
static QString | ConsumerIdToString (const int id) |
Private Attributes | |
unsigned long | CID |
QStringList | Consumers |
QList< int > | iConsumers |
bool | Locked |
bool | Managed |
Internal variable that contains a cache whether object is managed. | |
QMutex * | QL |
Static Private Attributes | |
static unsigned long | LastCID = 0 |
static QMutex | WideLock |
Base for all items that are supposed to be collected by garbage collector.
In order for any item to be maintained by garbage collector it must be inherited from this class. Every object by default when created is unmanaged, which means, that garbage collector doesn't care about it. In order to change it to managed object, you have to register at least one consumer. Once you do that, the class must not be explicitly deleted using delete, if you do that unrecoverable exception will be thrown. The class which is managed (you can verify that by calling Collectable::IsManaged) can be only deleted by garbage collector when no consumers are using it. Basically every object that has 0 consumers, will be deleted.
Definition at line 34 of file collectable.hpp.
unsigned long Collectable::CollectableID | ( | ) |
QString Collectable::DebugHgc | ( | ) |
DebugHgc.
Definition at line 137 of file collectable.cpp.
References CollectableID().
bool Collectable::IsLocked | ( | ) |
Whether the object is locked (other threads can't register nor unregister consumers neither it is possible to delete this object by any other thread)
Definition at line 162 of file collectable.cpp.
bool Collectable::IsManaged | ( | ) |
IsManaged Managed class is deleted by GC and must not be deleted by hand.
Definition at line 179 of file collectable.cpp.
References Managed.
Referenced by Huggle::GC::DeleteOld().
void Collectable::RegisterConsumer | ( | const int | consumer | ) |
Registers a consumer.
This function will store a string which prevent the object from being removed by GC, by calling this function you change type to managed
consumer | String that lock the object |
Definition at line 57 of file collectable.cpp.
References Lock(), and Unlock().
Referenced by Huggle::Core::AppendQuery(), Huggle::DeleteForm::checkDelToken(), Huggle::BlockUser::CheckToken(), Huggle::ProtectPage::checkTokenToProtect(), Huggle::ProcessList::ContainsQuery(), Huggle::MainWindow::Exit(), Huggle::Message::Finish(), Huggle::HuggleTool::FinishPage(), Huggle::UAAReport::getPageContents(), Huggle::DeleteForm::getToken(), Huggle::BlockUser::GetToken(), Huggle::ProtectPage::getTokenToProtect(), Huggle::ProcessList::InsertQuery(), Huggle::WikiEdit::PostProcess(), Huggle::Core::PostProcessEdit(), Huggle::EditQuery::Process(), Huggle::RevertQuery::Process(), Huggle::Query::ProcessCallback(), Huggle::EditQuery::Processed(), Huggle::MainWindow::ProcessEdit(), Huggle::RevertQuery::ProcessRevert(), Huggle::HuggleFeedProviderWiki::Refresh(), Huggle::ProcessList::RemoveQuery(), Huggle::Core::RevertEdit(), Huggle::RevertQuery::Rollback(), Huggle::Message::Send(), Huggle::ProcessList::UpdateQuery(), and Huggle::WikiEdit::WikiEdit().
void Collectable::RegisterConsumer | ( | const QString | consumer | ) |
Registers a consumer.
This function will store a string which prevent the object from being removed by QueryGC, by calling this function you change the query type to managed
consumer | String that lock the object |
Definition at line 76 of file collectable.cpp.
void Collectable::UnregisterConsumer | ( | const int | consumer | ) |
This function will remove a string which prevent the object from being removed.
consumer | Unique string that unlock the object |
Definition at line 68 of file collectable.cpp.
References Lock(), and Unlock().
Referenced by Huggle::BlockUser::Block(), Huggle::DeleteForm::checkDelToken(), Huggle::Core::CheckQueries(), Huggle::BlockUser::CheckToken(), Huggle::ProtectPage::checkTokenToProtect(), Huggle::ProcessList::ContainsQuery(), Huggle::DeleteForm::Delete(), Huggle::Core::DeleteEdit(), Huggle::Message::Fail(), Huggle::ProtectPage::Failed(), Huggle::DeleteForm::Failed(), Huggle::WikiEdit::FinalizePostProcessing(), Huggle::Message::Finish(), Huggle::Message::Finished(), Huggle::HuggleTool::FinishPage(), Huggle::ProcessList::InsertQuery(), Huggle::RevertQuery::Kill(), Huggle::UAAReport::onTick(), Huggle::Core::PostProcessEdit(), Huggle::EditQuery::Processed(), Huggle::RevertQuery::ProcessRevert(), Huggle::ProtectPage::Protect(), Huggle::HuggleFeedProviderWiki::Refresh(), Huggle::ProcessList::RemoveQuery(), Huggle::HuggleFeedProviderIRC::RetrieveEdit(), and Huggle::ProcessList::UpdateQuery().
void Collectable::UnregisterConsumer | ( | const QString | consumer | ) |
This function will remove a string which prevent the object from being removed.
consumer | Unique string that unlock the object |
Definition at line 85 of file collectable.cpp.