Class: Gl::GlInternalMarked
- Inherits:
-
Object
- Object
- Gl::GlInternalMarked
- Defined in:
- lib/opengl-core/aux/marked.rb
Direct Known Subclasses
Constant Summary collapse
- @@allocated__ =
{}
Class Method Summary collapse
-
.__marked_allocated__ ⇒ Object
private
Returns a Hash of marked objects.
-
.allocated ⇒ Object
private
Returns all allocated marked objects for this class.
-
.clear_all ⇒ Object
Clears all marked objects.
-
.delete_all ⇒ Object
Deletes all objects of the given type.
-
.inherited(subclass) ⇒ Object
private
Allocates a hash for the subclass.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#__mark__ ⇒ Object
private
Marks the class to prevent it from being garbage collected.
-
#__unmark__ ⇒ Object
private
Unmarks the class and allows it to be garbage collected.
-
#delete ⇒ Object
Should be overridden by subclasses to handle freeing resources when marked.
-
#marked? ⇒ Boolean
private
Returns whether the object is currently marked to keep it from being GC’d.
Class Method Details
.__marked_allocated__ ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a Hash of marked objects.
56 57 58 |
# File 'lib/opengl-core/aux/marked.rb', line 56 def self.__marked_allocated__ (@@allocated__[self.class] || (@@allocated__[self.class] = {})) end |
.allocated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all allocated marked objects for this class.
62 63 64 |
# File 'lib/opengl-core/aux/marked.rb', line 62 def self.allocated __marked_allocated__.keys end |
.clear_all ⇒ Object
Clears all marked objects. If deletion is already guaranteed for all marked objects, you may use this to let all marked objects of this type get GC’d.
25 26 27 |
# File 'lib/opengl-core/aux/marked.rb', line 25 def self.clear_all __marked_allocated__.clear end |
.delete_all ⇒ Object
Deletes all objects of the given type. Should be used carefully if at all.
19 20 21 |
# File 'lib/opengl-core/aux/marked.rb', line 19 def self.delete_all __marked_allocated__.keys.each { |marked| marked.delete } end |
.inherited(subclass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Allocates a hash for the subclass. This will be done regardless of whether this function is called.
50 51 52 |
# File 'lib/opengl-core/aux/marked.rb', line 50 def self.inherited(subclass) @@allocated__[subclass] = @@allocated__[subclass] || {} end |
Instance Method Details
#==(other) ⇒ Object
7 8 9 |
# File 'lib/opengl-core/aux/marked.rb', line 7 def ==(other) (self.kind_of?(other.class) || other.kind_of?(self.class)) && (self.name == other.name) end |
#__mark__ ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Marks the class to prevent it from being garbage collected.
31 32 33 |
# File 'lib/opengl-core/aux/marked.rb', line 31 def __mark__ self.class.__marked_allocated__[self] = true end |
#__unmark__ ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Unmarks the class and allows it to be garbage collected.
37 38 39 |
# File 'lib/opengl-core/aux/marked.rb', line 37 def __unmark__ self.class.__marked_allocated__.delete(self) end |
#delete ⇒ Object
Should be overridden by subclasses to handle freeing resources when marked. If unmarked, should be a no-op.
13 14 15 16 |
# File 'lib/opengl-core/aux/marked.rb', line 13 def delete __unmark__ self end |
#marked? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether the object is currently marked to keep it from being GC’d.
43 44 45 |
# File 'lib/opengl-core/aux/marked.rb', line 43 def marked? self.class.__marked_allocated__.include?(self) end |