view src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeRepository.java @ 19:703f0be5368a

added attribute cache
author Shoshi TAMAKI
date Thu, 20 Dec 2012 18:09:17 +0900
parents a46ff0114a9e
children
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl;

import java.util.concurrent.atomic.AtomicReference;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Constants;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.Operation;

import fj.data.List;

public class TreeRepository
{
	private final AtomicReference<DefaultChangeList> changeList;
	
	public TreeRepository()
	{
		List<Operation> emptyCommands = List.nil();
		
		changeList = new AtomicReference<DefaultChangeList>(
				new DefaultChangeList(DefaultTree.EMPTY,emptyCommands,
						Constants.DEFAULT_OWNER,Constants.DEFAULT_REVISION_START_NUMBER,null)
			);
	}
	
	public DefaultChangeList getCurrentChangeList()
	{
		return changeList.get();
	}
	
	public boolean commitChangeList(DefaultChangeList _newChangeList,DefaultChangeList _currentChangeList)
	{
		return changeList.compareAndSet(_currentChangeList,_newChangeList);
	}
}