/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.engine.internal.executor.emitter;

import java.util.LinkedList;

import org.eclipse.birt.report.engine.emitter.IContentEmitter;
import org.eclipse.birt.report.engine.executor.IReportItemExecutor;

public class ExecutorManager
{

	LinkedList executors = new LinkedList( );

	public ExecutorManager( )
	{

	}

	IReportItemExecutor createExecutor( IReportItemExecutor executor,
			IContentEmitter emitter )
	{
		ReportItemEmitterExecutor pooledExecutor = null;
		if ( executors.isEmpty( ) )
		{
			pooledExecutor = new PooledReportItemEmitterExecutor( this );
		}
		else
		{
			pooledExecutor = (ReportItemEmitterExecutor) executors.removeLast( );
		}
		pooledExecutor.executor = executor;
		pooledExecutor.emitter = emitter;
		return pooledExecutor;
	}

	void release( IReportItemExecutor executor )
	{
		executors.addLast( executor );
	}

}
