public class MemoryBuffer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.util.concurrent.locks.Lock |
lock
Safe lock for multithread access
|
Constructor and Description |
---|
MemoryBuffer(int maxCapacity,
RawMemory rawMemory)
Creates a MemoryBuffer.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all memory objects from this buffer.
|
java.util.List<MemoryObject> |
get()
Returns the original list of memory objects in this buffer.
|
java.util.ArrayList<MemoryObject> |
getAll()
Returns a copy of the list of memory objects in this buffer.
|
MemoryObject |
getMostRecent()
Gets the most recent Memory Object of this type.
|
MemoryObject |
getOldest()
Gets the oldest MemoryObject in this list.
|
boolean |
impendingAccess(Codelet accessing)
Safe access through reentrant locks.
|
MemoryObject |
pop()
Pops the first memory object that went into this list.
|
void |
printStatus()
Prints the status of the Buffer.
|
void |
put(MemoryObject content)
Adds one memory object.
|
void |
putList(java.util.List<MemoryObject> contents)
Adds a list of memory objects.
|
boolean |
remove(MemoryObject mo)
Removes this memory object from this buffer and eliminates it from raw
memory.
|
int |
size()
Gets the size of the list of Memory objects inside Buffer.
|
public volatile java.util.concurrent.locks.Lock lock
public MemoryBuffer(int maxCapacity, RawMemory rawMemory)
maxCapacity
- maximum number of elements this buffer holds at a given time.rawMemory
- singleton instance of the system's raw memory.public boolean impendingAccess(Codelet accessing)
accessing
- the accessing Codeletpublic void putList(java.util.List<MemoryObject> contents)
contents
- list of Memory Objects to be addedpublic void put(MemoryObject content)
content
- one memory object to be added.public java.util.List<MemoryObject> get()
public java.util.ArrayList<MemoryObject> getAll()
public MemoryObject pop()
public int size()
public MemoryObject getMostRecent()
public MemoryObject getOldest()
public boolean remove(MemoryObject mo)
mo
- memory object to be removed.public void clear()
public void printStatus()