How to implement simple MVCC datastructure

I am reading about different concurrency models and different features of concurrency, but no text talks about how to implement a simple MVCC data structure. Let us say I have to implement a simple Array based data structure which provided MVCC based concurrency. How should my code look like?

I understand that MVCC basically means: (Multiversion concurrency control)

1) Read isolation - your writes should not block reads

2) Timestamp based ordering for establishing happens-before relation/ordering.

Do I need to keep in mind any other aspects?

Also, my below code handles 1st requirement, but how to implement timestamp ordering?

class MVCCArray{

    private int[] arr;

    MVCCArray(int n){
        arr = new int[n];
    }


    //unblocking reads
    public int getItem(int index){
        return arr[index];
    }

    //blocking writes
    public synchronized void setItem(int index, int value){
        arr[index]=value;
    }

}


PS : I want to understand how it is implemented in a generic way. Please refrain from explaining how it is implemented in a particular database.

链接地址: http://www.djcxy.com/p/30610.html

上一篇: OrientDB是否实际实现了MVCC?

下一篇: 如何实现简单的MVCC数据结构