mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
GB: Refine lazy object GC. v5.0.114 (#3321)
* GB: Refine lazy object GC. 1. Remove gc_set_creator_wrapper, pass by resource constructor. 2. Remove SRS_LAZY_WRAPPER_GENERATOR macro, use template directly. 3. Remove interfaces ISrsGbSipConn and ISrsGbSipConnWrapper. 4. Remove ISrsGbMediaConn and ISrsGbMediaConnWrapper. * GC: Refine wrapper constructor. * GB: Refine lazy object GC. v5.0.114
This commit is contained in:
parent
7eaee46f1f
commit
6f3d6b9b65
8 changed files with 104 additions and 223 deletions
|
@ -43,23 +43,20 @@ ISrsConnection::~ISrsConnection()
|
|||
SrsLazyObject::SrsLazyObject()
|
||||
{
|
||||
gc_ref_ = 0;
|
||||
gc_creator_wrapper_ = NULL;
|
||||
}
|
||||
|
||||
SrsLazyObject::~SrsLazyObject()
|
||||
{
|
||||
}
|
||||
|
||||
SrsLazyObject* SrsLazyObject::gc_use()
|
||||
void SrsLazyObject::gc_use()
|
||||
{
|
||||
gc_ref_++;
|
||||
return this;
|
||||
}
|
||||
|
||||
SrsLazyObject* SrsLazyObject::gc_dispose()
|
||||
void SrsLazyObject::gc_dispose()
|
||||
{
|
||||
gc_ref_--;
|
||||
return this;
|
||||
}
|
||||
|
||||
int32_t SrsLazyObject::gc_ref()
|
||||
|
@ -67,16 +64,6 @@ int32_t SrsLazyObject::gc_ref()
|
|||
return gc_ref_;
|
||||
}
|
||||
|
||||
void SrsLazyObject::gc_set_creator_wrapper(ISrsResource* wrapper)
|
||||
{
|
||||
gc_creator_wrapper_ = wrapper;
|
||||
}
|
||||
|
||||
ISrsResource* SrsLazyObject::gc_creator_wrapper()
|
||||
{
|
||||
return gc_creator_wrapper_;
|
||||
}
|
||||
|
||||
ISrsLazyGc::ISrsLazyGc()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -55,24 +55,16 @@ class SrsLazyObject
|
|||
private:
|
||||
// The reference count of resource, 0 is no wrapper and safe to sweep.
|
||||
int32_t gc_ref_;
|
||||
// The creator wrapper, which created this resource. Note that it might be disposed and the pointer is NULL, so be
|
||||
// careful and make sure to check it before use it.
|
||||
ISrsResource* gc_creator_wrapper_;
|
||||
public:
|
||||
SrsLazyObject();
|
||||
virtual ~SrsLazyObject();
|
||||
public:
|
||||
// For wrapper to use this resource.
|
||||
virtual SrsLazyObject* gc_use();
|
||||
virtual void gc_use();
|
||||
// For wrapper to dispose this resource.
|
||||
virtual SrsLazyObject* gc_dispose();
|
||||
virtual void gc_dispose();
|
||||
// The current reference count of resource.
|
||||
virtual int32_t gc_ref();
|
||||
public:
|
||||
// Set the creator wrapper, from which resource clone wrapper.
|
||||
virtual void gc_set_creator_wrapper(ISrsResource* wrapper);
|
||||
// Get the first available wrapper. NULL if the creator wrapper disposed.
|
||||
virtual ISrsResource* gc_creator_wrapper();
|
||||
};
|
||||
|
||||
// The lazy-sweep GC, wait for a long time to dispose resource even when resource is disposable.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue