If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
frame as asm mem discussion
3 posts
• Page 1 of 1
frame as asm mem discussion
I've had this idea the other day. Ruby constants are never garbage-collected (unless you do something very fishy with classes). Perhaps we can create a Hash constant GLOBAL_FRAMES and then put frames into it by their rubyedit as a key. That way we wouldn't have to trigger the module to prevent garbage collection.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: frame as asm mem discussion
Careful with globals, specifically within Flowstone. We had a discussion about globals (and class variables, too) when Exo tried to find a way to have C-type callbacks.
Myco pointed out that not only one project uses only one Ruby, all running Flowstone projects share the same Ruby. And therefore a constant is valid for all those plugins and executables that run on your system. How should a plugin differentiate constants with the same name? It can't. So the first definition of a constant stays valid for all. With class variables you could at least manage some kind of inter-application-communication, although still not very safe. But with constants you're risking too much.
Myco pointed out that not only one project uses only one Ruby, all running Flowstone projects share the same Ruby. And therefore a constant is valid for all those plugins and executables that run on your system. How should a plugin differentiate constants with the same name? It can't. So the first definition of a constant stays valid for all. With class variables you could at least manage some kind of inter-application-communication, although still not very safe. But with constants you're risking too much.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: frame as asm mem discussion
Example code:
From what I can tell "self" is a unique object for each rubyedit, so no interference should happen (each rubyedit will have unique key for its personal frame). Also the "GLOBAL_FRAMES" constant is initialized only once. Unless some of your projects use constant with the same name for something else than storing frames this way, there should be no interference at all. AFAIK the rubyEdit instances should be each unique (even if multiple copies of the same project exist) in a role of hash key, right?
- Code: Select all
#declare constant if not declared yet
if not(GLOBAL_FRAMES)
GLOBAL_FRAMES=Hash.new(Frame.new(1) #hash with default value (empty frame)
end
def event(i,v,t) #input is an array
nf=Frame.new(v)
#here should be code, that outputs size and address of new frame
GLOBAL_FRAMES[self]=nf #notice that current rubyEdit is used as a key
end
From what I can tell "self" is a unique object for each rubyedit, so no interference should happen (each rubyedit will have unique key for its personal frame). Also the "GLOBAL_FRAMES" constant is initialized only once. Unless some of your projects use constant with the same name for something else than storing frames this way, there should be no interference at all. AFAIK the rubyEdit instances should be each unique (even if multiple copies of the same project exist) in a role of hash key, right?
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests