view rep/EditorList.java @ 356:b18c24dcc5d2

Before chaning put/join scheme for ditributed select.
author kono
date Sat, 18 Oct 2008 19:01:40 +0900
parents 5ba5b7a9761b
children 034acadc0cdc
line wrap: on
line source

package rep;

import java.util.LinkedList;

public class EditorList extends LinkedList<Editor> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int eid_root=0;
	private LinkedList<Editor> waiting= new LinkedList<Editor>();


	public void addWaitingEditor(Editor fw) {
		waiting.add(fw);
	}


	public void assignSessionManagerIDtoWaitingSM(int eid) {
		// 待っていたEditorにEditor IDを登録し,Session Manager List
		// に登録する。この後、EditorのPUT/JOINに従って、ACKを送り、EID
		// を確定する。
		Editor waiter;
		if ((waiter=waiting.poll())!=null) {
			waiter.setEID(eid);
			add(waiter);
			return;
		}
		assert false;
	}


	public int newEid() {
		return ++eid_root;
	}


	public boolean waiting(Editor editor) {
		return waiting.contains(editor);
	}


}