| Class | MUES::ObjectStore::TrainMemoryManager::MMCar |
| In: |
lib/mues/os-extensions/trainmemorymanager.rb
(CVS)
|
| Parent: | MUES::Object |
creates a new MMCar object, used in the train algorithm for memory management.
# File lib/mues/os-extensions/trainmemorymanager.rb, line 424 def initialize( m_m ) $stderr.puts "creating a new car" if $debug @memoryManager = m_m @objects = [] @maxSize = m_m.car_size @activeObjectReferences = m_m.activeObjectReferences @size = 0 end
puts the object(s) into the car, or raises a TrainError if there isn‘t sufficent room on this car. currently only counts each object as 1 space, not taking into account instance vars that aren‘t StorableObjects, or even just looking at Marshal.dump return length. this also doesn‘t handle reassigning the
# File lib/mues/os-extensions/trainmemorymanager.rb, line 460 def addObj( *obj ) obj.to_a.each {|o| @size = @size + 1 @mutex.synchronize( Sync::EX ) { @objects << o } } @objects.compress! # get rid of duplicates end
returns whether or not the car is full
# File lib/mues/os-extensions/trainmemorymanager.rb, line 441 def full? @maxSize <= @size end