Package org.deuce.transaction.tl2cm.contexts

Source Code of org.deuce.transaction.tl2cm.contexts.ArrayContextsMap

package org.deuce.transaction.tl2cm.contexts;

import org.deuce.transaction.tl2cm.Context;
import org.deuce.transaction.tl2cm.Status;
import org.deuce.transform.Exclude;

/**
* @author Yoav Cohen, yoav.cohen@cs.tau.ac.il
* @since 1.2
*/
@Exclude
public class ArrayContextsMap implements ContextsMap {

  private final Context[] arr = new Context[256];
 
  public Context get(int threadId) {
    Context context = arr[threadId];
    if (Status.INACTIVE != context.getStatus()) {
      return context;
    }
    else {
      return null;
    }
  }

  public final void put(int threadId, Context context) {
    arr[threadId] = context;
  }

  public final void remove(int threadId) {
    arr[threadId].setStatus(Status.INACTIVE);
  }

}
TOP

Related Classes of org.deuce.transaction.tl2cm.contexts.ArrayContextsMap

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.