Package: com.multiversesocial.hyperview
Class: com.multiversesocial.hyperview.InterProcessMemory
Source: src/com/multiversesocial/hyperview/InterProcessMemory.java

InterProcessMemory

HyperView V3.2 — class
version V3.2 class

Summary

This class is a "simple" implementation of interprocess shared memory. By Tony Swain Jan 13 2013 416478

Source file: InterProcessMemory.java

Hierarchy

Extends: Linkable

Implements: InterProcessMemoryConstants, Runnable, MemoryInitializer

Referenced HyperView classes

Media files used

Declaration & members

public class InterProcessMemory extends Linkable implements InterProcessMemoryConstants, Runnable, MemoryInitializer

Declared in src/com/multiversesocial/hyperview/InterProcessMemory.java, lines 17–2432. 27 field(s), 4 constructor(s), 74 method(s), plus 1 nested type(s). Every member has an anchor you can link to (e.g. InterProcessMemory.html#<id>).

Fields (27)

DeclarationValue / initializerDescriptionSource
volatile HyperLinkedList fieldListA List to map in Field Types that comprise the memory blockline 31
volatile RandomAccessFile fileNo comment in source; assigned in purge().line 41
volatile FileChannel fileChannelNo comment in source; assigned in purge(); used in seek(), lockRegion(), lock(), blockingLock(), saveToDevice() ….line 40
volatile String fileNameNo comment in source; assigned in InterProcessMemory(); used in purge().line 39
static volatile int fp0Yeh ole 32 bit file pointer.line 50
static volatile long fp1No comment in source; not referenced by name in this type’s methods.line 51
Graphics graphicsNo comment in source; not referenced by name in this type’s methods.line 23
static volatile int indeces= 0No comment in source; not referenced by name in this type’s methods.line 30
volatile int indexin memory list.line 47
InterProcessMemory innerParentSo inner classes can make direct refererencesline 26
volatile HyperLinkedList listenerListNo comment in source; assigned in InterProcessMemory(); used in run(), listenerWait(), purge().line 32
public volatile Thread listenerThreadNo comment in source; assigned in start(), stop(), run(); used in lockRegion(), lock(), saveToDevice().line 25
MappedByteBuffer mappedByteBufferA memory mapped Byte Buffer.line 37
volatile int memFlagsNo comment in source; assigned in setDataAligned(), setDataUnAligned(), setBitWidth(), lock(), start() …; used in readInt(), writeInt(), readShort(), writeShort(), getBitWidth() ….line 34
String memNameNo comment in source; assigned in InterProcessMemory(); used in erase(), exists().line 35
MemoryInitializer memoryInitializerNo comment in source; assigned in setMemoryInitializer().line 22
static volatile HyperLinkedList memoryListNo comment in source; used in addListener(), removeListener(); name appears in 1 other source file(s): ViewMemory.line 29
int memoryModeAllows 32-64 bit reference switchline 45
InterProcessMemory.MemorySaveTimer memoryTimerNo comment in source; assigned in enableBackupTimer(); used in disableBackupTimer(), setUpdateMillis().line 27
int memoryTypeNo comment in source; not referenced by name in this type’s methods.line 46
volatile int memSizeNo comment in source; assigned in InterProcessMemory(); used in seek(), readInt(), writeInt(), readShort(), writeShort() ….line 48
volatile long memSizeLongNo comment in source; not referenced by name in this type’s methods.line 49
static int processIndex= 0No comment in source; not referenced by name in this type’s methods.line 21
int processNumberNo comment in source; not referenced by name in this type’s methods.line 24
long startTimeNo comment in source; name appears in 15 other source file(s): Asteroids, CollisionManager, HyperChannel, HyperConnectionHandler ….line 28
static int totalProcesses= 0No comment in source; name appears in 1 other source file(s): HyperProcess.line 20
volatile long updateMillisNo comment in source; assigned in InterProcessMemory(), enableBackupTimer(), setUpdateMillis().line 33

Constructors (4)

SignatureDescriptionSource
InterProcessMemory()1 statement(s); calls this().line 53
InterProcessMemory(int tSize)6 statement(s); calls super(); creates HyperLinkedList.line 58
InterProcessMemory(String tName, int tSize)7 statement(s); calls super(); creates HyperLinkedList.line 72
InterProcessMemory(long tUpdateMillis, int tSize)2 statement(s); calls this().line 87

Methods (74)

SignatureDescriptionSource
static { … }Implicit default constructor generated by the compiler (not written in the source).implicit
public void addListener(SharedMemoryListener tSharedMemoryListener)1 statement(s); calls memoryList.dlStore(), memoryList.notifyAll().line 2244
public void appendFieldList(HyperLinkedList tList)1 statement(s); calls fieldList.dlStore(), notifyAll().line 2204
public FileLock blockingLock(int tStart, int tLength)6 statement(s); calls fileChannel.lock(), flie.toString(), olfle.toString(), nwce.toString(), cce.toString() ….line 879
int close()5 statement(s); calls tList.dlDelete(), tList.notifyAll(), tMemory.fileChannel.close().line 1628
static int close(String tName)5 statement(s); calls tMemory.memName.equals(), tList.dlDelete(), tMemory.fileChannel.close(), tList.notifyAll().line 1592
public void disableBackupTimer(int tMillies)2 statement(s); calls memoryTimer.stop().line 2276
public void enableBackupTimer(int tMillies)4 statement(s); calls memoryTimer.start(); creates MemorySaveTimer.line 2262
public void erase()Zero the mapped region and force to device.
Implements MemoryInitializer.erase()
line 1355
public boolean exists()3 statement(s); calls tFile.exists(); creates File.line 2322
public byte getBitWidth()6 statement(s).line 526
public void isLoaded()1 statement(s); calls mappedByteBuffer.isLoaded().line 1344
public boolean isResident()Returns ((memFlags & MEM_RESIDENT) == 0 ? false : true).line 2312
public void listenerWait()1 statement(s); calls listenerList.notifyAll(), listenerList.wait().line 1240
public void load()Load Memory from backing fileline 1338
public static void loadMemoryList()update the all memory from the device.line 1314
public FileLock lock()6 statement(s); calls fileChannel.lock(), flie.toString(), olfle.toString(), nwce.toString(), cce.toString() ….line 651
public FileLock lock(int tFlags)8 statement(s); calls fileChannel.lock(), flie.toString(), olfle.toString(), nwce.toString(), cce.toString() ….line 975
public FileLock lock(int tFlags, int tStart, int tLength)8 statement(s); calls fileChannel.lock(), flie.toString(), olfle.toString(), nwce.toString(), cce.toString() ….line 765
public FileLock lockRegion(long tPosition, long tSize)5 statement(s); calls fileChannel.lock(), flie.toString(), olfle.toString(), nwce.toString(), cce.toString() ….line 548
public static void main(String[] argv) throws Exception16 statement(s); calls ProcessID.getProcessString(), InterProcessMemory.open(), tInterProcessMemory.setResident(), tInterProcessMemory.readInt(), tInterProcessMemory.writeInt() …; creates Object.line 2388
static int notifyListeners()Returns 1.line 1350
static InterProcessMemory open(InterProcessMemory tInterProcessMemory) throws IllegalAccessException9 statement(s); calls tInterProcessMemory.exists(), tMemory.memName.equals(), tInterProcessMemory.file.getChannel(), tInterProcessMemory.fileChannel.map(), any.printStackTrace() …; creates HyperLinkedList, IllegalAccessException, RandomAccessFile.line 1388
static InterProcessMemory open(String tName)Returns InterProcessMemory.open(tName, (MemoryInitializer)null).line 1458
static InterProcessMemory open(String tName, MemoryInitializer tMemoryInitializer)6 statement(s); calls tMemory.memName.equals(), tList.notifyAll(), tMemory.file.getChannel(), tMemory.fileChannel.map(), any.printStackTrace() …; creates HyperLinkedList, InterProcessMemory, RandomAccessFile.line 1463
static InterProcessMemory open(String tName, int tSize)Returns InterProcessMemory.open(tName, tSize, (MemoryInitializer)null).line 1517
static InterProcessMemory open(String tName, int tSize, MemoryInitializer tMemoryInitializer)8 statement(s); calls tMemory.memName.equals(), tList.notifyAll(), tFile.exists(), tMemory.file.getChannel(), tMemory.fileChannel.map() …; creates HyperLinkedList, InterProcessMemory, File.line 1523
public void purge()If the Memory is not resident then delete it from the system.line 1257
public byte read() throws IllegalMemoryAccessException10 statement(s); calls lock(), mappedByteBuffer.position(), mappedByteBuffer.get(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 1805
public int read(int[] tInt, int tOffset) throws IllegalMemoryAccessException13 statement(s); calls fileChannel.lock(), mappedByteBuffer.position(), mappedByteBuffer.getInt(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 1862
public int read(byte[] tByte, int tOffset, int tLength) throws IllegalMemoryAccessException11 statement(s); calls lock(), mappedByteBuffer.position(), mappedByteBuffer.get(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 1914
public byte readDirect() throws IllegalMemoryAccessException8 statement(s); calls mappedByteBuffer.position(), mappedByteBuffer.get(); creates IllegalMemoryAccessException.line 2078
public int readDirect(int[] tInt, int tOffset) throws IllegalMemoryAccessException10 statement(s); calls mappedByteBuffer.position(), mappedByteBuffer.getInt(); creates IllegalMemoryAccessException.line 2133
public int readDirect(byte[] tByte, int tOffset, int tLength) throws IllegalMemoryAccessException8 statement(s); calls mappedByteBuffer.position(), mappedByteBuffer.get(); creates IllegalMemoryAccessException.line 2156
public int readInt() throws IllegalMemoryAccessException12 statement(s); calls lock(), mappedByteBuffer.getInt(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 139
public int readInt(int tOffset) throws IllegalMemoryAccessException12 statement(s); calls lock(), mappedByteBuffer.getInt(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 177
public int readInt(int tOffset, int[] tInInt) throws IllegalMemoryAccessException13 statement(s); calls lock(), mappedByteBuffer.position(), mappedByteBuffer.getInt(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 218
public int readIntDirect(int tOffset) throws IllegalMemoryAccessException9 statement(s); calls mappedByteBuffer.getInt(); creates IllegalMemoryAccessException.line 2094
public short readShort() throws IllegalMemoryAccessException13 statement(s); calls lock(), mappedByteBuffer.position(), mappedByteBuffer.getShort(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 392
public short readShort(int tOffset) throws IllegalMemoryAccessException13 statement(s); calls lock(), mappedByteBuffer.position(), mappedByteBuffer.getShort(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 430
public void remakeFieldList(HyperLinkedList tList)1 statement(s); calls fieldList.drain(), fieldList.dlStore(), notifyAll().line 2185
public void removeListener(SharedMemoryListener tSharedMemoryListener)1 statement(s); calls memoryList.dlDelete(), memoryList.notifyAll().line 2253
public void run()5 statement(s); calls Thread.currentThread(), lock(), tMemoryFieldLink.onMemoryChange(), listenerList.notifyAll(), tLock.release() ….
Implements Runnable.run()
line 1115
public int saveToDevice()Copy memory to deviceline 1175
public int seek(int tInt) throws IllegalMemoryAccessException6 statement(s); calls lock(), fileChannel.position(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 113
public void setBitWidth(byte tBitWidth) throws IllegalMemoryAccessException1 statement(s); creates IllegalMemoryAccessException.line 502
public void setDataAligned()Set the data to be aligned to the device memory typeline 101
public void setDataUnAligned()1 statement(s).line 108
public void setFieldList(HyperLinkedList tList)1 statement(s).line 2177
public void setMemoryInitializer(MemoryInitializer tMemoryInitializer)Sets memoryInitializer = tMemoryInitializer.line 95
public void setResident()1 statement(s).line 2307
void setUpdateMillis(long tUpdateMillis)5 statement(s); calls tThread.interrupt(), memoryTimer.start().line 2285
public void start()5 statement(s); calls tThread.interrupt(), listenerThread.start(); creates Thread.line 1091
public void stop()3 statement(s); calls tThread.interrupt().line 1104
public String toString()7 statement(s); calls mappedByteBuffer.limit(), mappedByteBuffer.get(), tStringBuilder.append(), tStringBuilder.toString(); creates StringBuilder.
Overrides Object.toString()
line 2217
public void unsetResident()1 statement(s).line 2317
public int write(byte tByte) throws IllegalMemoryAccessException9 statement(s); calls lock(), mappedByteBuffer.put(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 1663
public int write(byte[] tByte) throws IllegalMemoryAccessException9 statement(s); calls lock(), mappedByteBuffer.put(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 1691
public int write(String tString) throws IllegalMemoryAccessException13 statement(s); calls tString.length(), lock(), mappedByteBuffer.position(), mappedByteBuffer.put(), tString.getBytes() …; creates IllegalMemoryAccessException.line 1747
public int write(byte[] tByte, int tOffset, int tLength) throws IllegalMemoryAccessException9 statement(s); calls lock(), mappedByteBuffer.position(), mappedByteBuffer.put(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 1719
public int write(String tString, int tOffset, int tLength) throws IllegalMemoryAccessException10 statement(s); calls lock(), tString.length(), mappedByteBuffer.position(), mappedByteBuffer.put(), tString.getBytes() …; creates IllegalMemoryAccessException.line 1777
public int writeDirect(byte tByte) throws IllegalMemoryAccessException6 statement(s); calls mappedByteBuffer.put(); creates IllegalMemoryAccessException.line 1954
public int writeDirect(byte[] tByte) throws IllegalMemoryAccessException6 statement(s); calls mappedByteBuffer.put(); creates IllegalMemoryAccessException.line 1968
public int writeDirect(String tString) throws IllegalMemoryAccessException11 statement(s); calls tString.length(), mappedByteBuffer.position(), mappedByteBuffer.put(), tString.getBytes(); creates IllegalMemoryAccessException.line 1996
public int writeDirect(byte[] tByte, int tOffset, int tLength) throws IllegalMemoryAccessException6 statement(s); calls mappedByteBuffer.position(), mappedByteBuffer.put(); creates IllegalMemoryAccessException.line 1982
public int writeDirect(String tString, int tOffset, int tLength) throws IllegalMemoryAccessException8 statement(s); calls tString.length(), mappedByteBuffer.position(), mappedByteBuffer.put(), tString.getBytes(); creates IllegalMemoryAccessException.line 2013
public int writeInt(int tInt) throws IllegalMemoryAccessException11 statement(s); calls lock(), mappedByteBuffer.putInt(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 260
public int writeInt(int tOffset, int tInt) throws IllegalMemoryAccessException10 statement(s); calls lock(), System.exit(), mappedByteBuffer.putInt(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 301
public int writeInt(int tOffset, int[] tInt) throws IllegalMemoryAccessException12 statement(s); calls lock(), System.exit(), mappedByteBuffer.putInt(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 344
public int writeIntDirect(int tInt) throws IllegalMemoryAccessException8 statement(s); calls mappedByteBuffer.putInt(); creates IllegalMemoryAccessException.line 2028
public int writeIntDirect(int tOffset, int tInt) throws IllegalMemoryAccessException7 statement(s); calls mappedByteBuffer.putInt(); creates IllegalMemoryAccessException.line 2051
int writeRegion(byte[] tByte, int tOffset, int tLength) throws IllegalMemoryAccessException9 statement(s); calls lock(), mappedByteBuffer.position(), mappedByteBuffer.put(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 1834
int writeRegionDirect(byte[] tByte, int tOffset, int tLength) throws IllegalMemoryAccessException6 statement(s); calls mappedByteBuffer.position(), mappedByteBuffer.put(); creates IllegalMemoryAccessException.line 2119
public int writeShort(int tOffset, short tShort) throws IllegalMemoryAccessException10 statement(s); calls lock(), mappedByteBuffer.putShort(), tLock.release(), ioex.printStackTrace(); creates IllegalMemoryAccessException.line 467

Nested & additional classes

MemorySaveTimer (nested type, lines 2334–2386)

class MemorySaveTimer implements Runnable

Fields (1)

DeclarationValue / initializerDescriptionSource
Thread memorySaveThreadNo comment in source; assigned in start(), stop(); used in run().line 2336

Constructors (1)

SignatureDescriptionSource
MemorySaveTimer()2 statement(s); calls super().line 2338

Methods (3)

SignatureDescriptionSource
public void run()2 statement(s); calls Thread.currentThread(), innerParent.notifyAll(), innerParent.wait(), saveToDevice().
Implements Runnable.run()
line 2363
public void start()3 statement(s); calls stop(), memorySaveThread.start(); creates Thread.line 2343
public void stop()3 statement(s); calls tThread.interrupt().line 2353

Inherited members

Non-private members inherited from HyperView superclasses and not overridden or hidden here.

From Linkable (6 fields, 2 methods)

Fields: attachment, linkFlags, name, next, parentList, prev

Methods: inList(), setName(String)

Examples

Real usage taken from elsewhere in the HyperView 3.2 source (file and line shown; source path src/com/multiversesocial/hyperview/).

subclass — ViewMemory.java, line 17

   17  public class ViewMemory extends InterProcessMemory implements ViewMemoryConstants,
   18  MessagePortConstants, SharedMemoryListener, MemoryInitializer
   19  {
Hits--