|
|
|
1 - Using SharedHashMap |
2 - "no-copy" mode |
3 - Concurrency handling and thread safety |
4 - Appendix: interfaces supported |
View All
In this article Jack Shirazi and Peter Lawrey give a worked example of using SharedHashMap, a high performance persisted off-heap hash map, shareable across processes.Published March 2014, Authors Jack Shirazi and Peter Lawrey
The generic method interfaces supported include
//Bean field accesser //TYPE getFIELDNAME(); int getValue(); //example //Bean field updater //void setFIELDNAME(TYPE value); void setValue(int value); //example //Bean field adder //TYPE addFIELDNAME(TYPE delta); int addValue(int delta); //example //Bean field atomic adder //TYPE addAtomicFIELDNAME(TYPE delta); int addAtomicValue(int delta); //example //Bean array-field accesser //TYPE getFIELDNAMEAt(int index); double getElementAt(int index); //example //Bean array-field updater //void setFIELDNAMEAt(@MaxSize(MAXSIZE) int index, TYPE value); void setElementAt(@MaxSize(4) int index, double value); //example //Bean field CAS updater //boolean compareAndSwapFIELDNAME(TYPE expected, TYPE value); boolean compareAndSwapValue(int expected, int value); //example //Try to acquire lock immediately //boolean tryLockLOCKNAME(); boolean tryLockMyLock(); //example //Try to acquire lock within nanos nanoseconds //boolean tryLockNanosLOCKNAME(long nanos); boolean tryLockNanosMyLock(long nanos); //example //Keep trying in a busy loop to acquire the lock //void busyLockLOCKNAME() throws InterruptedException, IllegalStateException; void busyLockMyLock() throws InterruptedException, IllegalStateException; //example //Unlock a locked lock, throwing exception if it's not locked void unlockLOCKNAME() throws IllegalMonitorStateException; void unlockMyLock() throws IllegalMonitorStateException; //example
1 - Using SharedHashMap |
2 - "no-copy" mode |
3 - Concurrency handling and thread safety |
4 - Appendix: interfaces supported |
View All