Cog reuse for repeated object instances in different object layers?
JasonE
Posts: 16
Hi, here's my question: (I hope I can explain what I'm thinking clearly)
· If I need to re-use an·object (floatmath) in my main application and in other·object subroutines, can I keep my cog use (for floatmath) down to 1 cog for that?·
For example say I have an application method called main that uses floatmath.· Let's also say that main calls another object I've written called Do_calculation that also invokes floatmath.· In this scenario two cogs for floatmath are running, one for the main method and one for the Do_calculation object.· However, I really don't need·2 cogs running floatmath as all calculations will be sequential for this particular application.
··Is there a way to pass the use of the floatmath object from main·into the lower Do_calculation object and minimize cog use?·
(I do realize I could manually start and stop the floatmath object in each method of the Do_calculation object and before and after floatmath operations in main, but that would be clumsy and awkward.)
-JasonE
· If I need to re-use an·object (floatmath) in my main application and in other·object subroutines, can I keep my cog use (for floatmath) down to 1 cog for that?·
For example say I have an application method called main that uses floatmath.· Let's also say that main calls another object I've written called Do_calculation that also invokes floatmath.· In this scenario two cogs for floatmath are running, one for the main method and one for the Do_calculation object.· However, I really don't need·2 cogs running floatmath as all calculations will be sequential for this particular application.
··Is there a way to pass the use of the floatmath object from main·into the lower Do_calculation object and minimize cog use?·
(I do realize I could manually start and stop the floatmath object in each method of the Do_calculation object and before and after floatmath operations in main, but that would be clumsy and awkward.)
-JasonE
Comments
There's no simple way to share the use of something like the floating point package among several objects. It's possible to write objects so they can be used this way by putting their shared variables in a DAT section rather than a VAR section, but then you can run into problems when you want multiple instances of the object. For example, there's a debug object that uses serial I/O. It has to be specifically written to work when included in multiple objects because it needs to provide only a single serial I/O channel.
Thank you for the guidance. I guess what I was imagining and hoping for was some sort of global object declaration.
A guy can dream, can't he? [noparse]:)[/noparse]