We have several asserts to ensure that delete-on-destroy sources are not misused, like not scheduling socket sources on a delete on destroy GMainLoopSource or not allowing to cancel them before they have been dispatched. It would be better if we can ensure all those things at compile time, so instead of having static method to create a delete-on-destroy source with all the API available, we could add static methods to schedule sources creating a delete-on-destroy GMainLoopSource that is not returned to the user.
Created attachment 238309 [details] Patch
Created attachment 238310 [details] Patch
Comment on attachment 238310 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=238310&action=review > Source/WTF/wtf/gobject/GMainLoopSource.cpp:36 > -GMainLoopSource& GMainLoopSource::createAndDeleteOnDestroy() > +GMainLoopSource& GMainLoopSource::create() I think this name should be kept, otherwise it may lead people to believe that this is the default or only way of creating, like on other objects, it gets confusing. > Source/WTF/wtf/gobject/GMainLoopSource.cpp:-85 > - // Delete-on-destroy GMainLoopSource objects can only be cancelled when there's callback either scheduled > - // or in the middle of dispatch. At that point cancellation will have no effect. > - ASSERT(m_deleteOnDestroy != DeleteOnDestroy || (m_status == Ready && !m_context.source)); Heh, this was a bit weird.
(In reply to comment #3) > (From update of attachment 238310 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=238310&action=review > > > Source/WTF/wtf/gobject/GMainLoopSource.cpp:36 > > -GMainLoopSource& GMainLoopSource::createAndDeleteOnDestroy() > > +GMainLoopSource& GMainLoopSource::create() > > I think this name should be kept, otherwise it may lead people to believe that this is the default or only way of creating, like on other objects, it gets confusing. But I made it private for that reason, so it can only be created inside the object. > > Source/WTF/wtf/gobject/GMainLoopSource.cpp:-85 > > - // Delete-on-destroy GMainLoopSource objects can only be cancelled when there's callback either scheduled > > - // or in the middle of dispatch. At that point cancellation will have no effect. > > - ASSERT(m_deleteOnDestroy != DeleteOnDestroy || (m_status == Ready && !m_context.source)); > > Heh, this was a bit weird. Yes.
Committed r173749: <http://trac.webkit.org/changeset/173749>