package org.kne.opencl64.concurrent;

import org.kne.opencl64.OpenCLContext;
import org.kne.opencl64.OpenCLMemory;

public class ThreadLocalOpenCLMemory extends ThreadLocal<OpenCLMemory> {

	public OpenCLMemory get(OpenCLContext context,long size) {
		OpenCLMemory ocm=super.get();
		if(ocm==null||ocm.byteSize()<size) {
			if(ocm!=null) {
				ocm.close();
			}
			ocm=new OpenCLMemory(context, size);
			super.set(ocm);
		}
		return ocm;
	}
	
	
}
