I find that I have several programs that rely on at base set of
programs. Lets say I have some modules called Common, Maya,
Composer, Paint. Maya, Composer, and Paint all have the base module
Common as a prereq. What I would like to do in Common is implement
some kind of reference counting scheme.
When module Common is loaded the first time it executes all the
"load" commands and sets it's reference count to 1. Each additional
time the module Common is loaded only the reference count is
incremented. When the module Common is unloaded the reference count
is decremented. When the reference count reaches zero then the
"unload" commands are executed.
So going back to my example:
module add Maya - This internally adds Common. Assuming module
Common was not previously loaded, Common is now
loaded and the reference count is 1.
module add Composer - This internally adds Common. Only the
reference count is incremented. The reference
count is now 2.
module rm Maya - This internally removes Common. The reference
count is now 1.
module add Paint - This internally adds Common. The reference
count is now 2.
module rm Paint - This internally removes Common. The reference
count is now 1.
module rm Composrer - This internally removes Common. The reference
count is now 0 so Common's "unload" commands
are now run.
I have not thought what would happen if I do a module switch on
Common.
Robert Minsk Centropolis Effects, LLC.
eg...@ce... 10950 Washington Blvd., Studio B
Culver City, Ca. 90232-4025
|