Class MUES::ObjectStore::TrainMemoryManager::MMCar
In: lib/mues/os-extensions/trainmemorymanager.rb  (CVS)
Parent: MUES::Object

Methods

addObj   full?   new   objectCount   objects   spaceLeft  

Public Class methods

creates a new MMCar object, used in the train algorithm for memory management.

[Source]

# 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

Public Instance methods

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

[Source]

# 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

[Source]

# File lib/mues/os-extensions/trainmemorymanager.rb, line 441
                def full? 
                    @maxSize <= @size
                end

returns the number of objects in the trainyard

[Source]

# File lib/mues/os-extensions/trainmemorymanager.rb, line 436
                def objectCount 
                    @objects.length
                end

returns the objects that belong to this car

[Source]

# File lib/mues/os-extensions/trainmemorymanager.rb, line 446
                def objects 
                    @objects
                end

returns the amount of space left on this car

[Source]

# File lib/mues/os-extensions/trainmemorymanager.rb, line 451
                def spaceLeft 
                    @maxSize - @size
                end

[Validate]