[gmpi] Re: Linux C++ question

On Thu, Feb 24, 2005 at 04:42:45PM -0500, Paul Davis wrote:
> >Example:  You want to unload a DLL.  You've destructed any plugin
> >instances.  You can then destruct the factory and release the DLL.


my language was off on that.  It should have read:

You want to unload a DLL.  You've called ::Release() for all Plugin
instances (thereby destructing them).  You call ::Release() for the
Factory instance.  You are then allowed to unload the DLL.

Unloading the DLL without calling ::Release() on every object from that
DLL is a logic bug.  The same as you would not deref a pointer after
free(), you don't want to do ANYTHING with a DLL after you unload it.

With a static Factory object, the ::Release() did nothing, and the
destructor is called when the DLL is unloaded (on platforms that work,
not mine).  This is the same net result, but the logic is b0rken.  The
::Release()  method really should release.  When the refcount hits 0,
the Factory is gone.

> which is semantically equivalent to Jeff's suggestion of a
> PreDLLUnload function, except that you are now tying it to the

Having a PreDllUnload is not a bad idea, per se, it's just not the right
answer here, I think.  The lifetime rules ought to be very clear:  when
the refcount hits 0, the object is no longer safe to reference.

Changing the static Factory instance into a dynamic instance makes it
follow these rules.


Are we arguing or agreeing?

----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: http://www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: