mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Add important comment for disposing and thread stop
This commit is contained in:
parent
e4df2eb2ce
commit
55bdc354f5
2 changed files with 8 additions and 2 deletions
|
@ -47,8 +47,11 @@ public:
|
|||
virtual ~ISrsDisposingHandler();
|
||||
public:
|
||||
// When before disposing resource, trigger when manager.remove(c), sync API.
|
||||
// @remark Recommend to unref c, after this, no other objects refs to c.
|
||||
virtual void on_before_dispose(ISrsResource* c) = 0;
|
||||
// When disposing resource, async API, c is freed after it.
|
||||
// @remark Recommend to stop any thread/timer of c, after this, fields of c is able
|
||||
// to be deleted in any order.
|
||||
virtual void on_disposing(ISrsResource* c) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -207,13 +207,14 @@ srs_error_t SrsFastCoroutine::start()
|
|||
void SrsFastCoroutine::stop()
|
||||
{
|
||||
if (disposed) {
|
||||
// TODO: FIXME: If previous stop is wait on st_thread_join, this call should assert fail.
|
||||
return;
|
||||
}
|
||||
disposed = true;
|
||||
|
||||
interrupt();
|
||||
|
||||
// When not started, the rd is NULL.
|
||||
// When not started, the trd is NULL.
|
||||
if (trd) {
|
||||
void* res = NULL;
|
||||
int r0 = st_thread_join((st_thread_t)trd, &res);
|
||||
|
@ -246,6 +247,8 @@ void SrsFastCoroutine::interrupt()
|
|||
trd_err = srs_error_new(ERROR_THREAD_INTERRUPED, "interrupted");
|
||||
}
|
||||
|
||||
// Note that if another thread is stopping thread and waiting in st_thread_join,
|
||||
// the interrupt will make the st_thread_join fail.
|
||||
st_thread_interrupt((st_thread_t)trd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue