hook the plugin refcounting in
The plugin refcounter is driven from interface opening/closing, this is quite internal. The 'last' time in plugin now records the last time the refcounter dropped to 0, this is just sufficient enough to find out how long a plugin is unused.
This commit is contained in:
parent
7afce647fb
commit
fa6b6d54e9
3 changed files with 11 additions and 5 deletions
|
|
@ -22,6 +22,7 @@
|
|||
#include "lib/mutex.h"
|
||||
#include "lib/safeclib.h"
|
||||
|
||||
#include "backend/plugin.h"
|
||||
#include "backend/interface.h"
|
||||
|
||||
#include "backend/interfaceregistry.h"
|
||||
|
|
@ -133,8 +134,9 @@ depwalk (LumieraInterfacenode self, LumieraInterfacenode* stack)
|
|||
|
||||
if (!cycle)
|
||||
{
|
||||
if ((*dep)->plugin)
|
||||
lumiera_plugin_refinc ((*dep)->plugin);
|
||||
++(*dep)->refcnt;
|
||||
|
||||
(*dep)->lnk = *stack;
|
||||
*stack = *dep;
|
||||
|
||||
|
|
@ -184,7 +186,10 @@ lumiera_interface_open_interfacenode (LumieraInterfacenode self)
|
|||
|
||||
if (!cycle)
|
||||
{
|
||||
if (self->plugin)
|
||||
lumiera_plugin_refinc (self->plugin);
|
||||
++self->refcnt;
|
||||
|
||||
self->lnk = stack;
|
||||
stack = self;
|
||||
int collect_dependencies_bak = collect_dependencies;
|
||||
|
|
@ -290,6 +295,8 @@ lumiera_interfacenode_close (LumieraInterfacenode self)
|
|||
|
||||
stack = self->lnk;
|
||||
self->lnk = NULL;
|
||||
if (self->plugin)
|
||||
lumiera_plugin_refdec (self->plugin);
|
||||
--self->refcnt;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ lumiera_interfacenode_new (LumieraInterface iface, LumieraPlugin plugin)
|
|||
self->interface = iface;
|
||||
self->refcnt = 0;
|
||||
self->plugin = plugin;
|
||||
FIXME ("plugin handling (refcnt, atime)");
|
||||
self->lnk = NULL;
|
||||
self->deps_size = 0;
|
||||
self->deps = NULL;
|
||||
|
|
@ -80,7 +79,6 @@ lumiera_interfacenode_delete (LumieraInterfacenode self)
|
|||
if (self)
|
||||
{
|
||||
REQUIRE (self->refcnt == 0);
|
||||
FIXME ("plugin handling");
|
||||
lumiera_free (self->deps);
|
||||
lumiera_free (self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ struct lumiera_plugin_struct
|
|||
/* use count for all interfaces of this plugin */
|
||||
unsigned refcnt;
|
||||
|
||||
/* time when the last open or close action happened */
|
||||
/* time when the refcounter dropped to 0 last time */
|
||||
time_t last;
|
||||
|
||||
/* when loading plugins en masse we do not want to fail completely if one doesnt cooperate, instead we record local errors here */
|
||||
|
|
@ -180,7 +180,8 @@ lumiera_plugin_refinc (LumieraPlugin self)
|
|||
void
|
||||
lumiera_plugin_refdec (LumieraPlugin self)
|
||||
{
|
||||
--self->refcnt;
|
||||
if (!--self->refcnt)
|
||||
time (&self->last);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue