/*
 *  Copyright (C) 2011 The Animo Project
 *  http://animotron.org
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 3
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
package org.animotron;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.animotron.manipulator.Channels;
import org.animotron.manipulator.Manipulator;
import org.neo4j.graphdb.PropertyContainer;

/**
 * @author <a href="mailto:gazdovsky@gmail.com">Evgeny Gazdovsky</a>
 *
 */
public class Executor {
	
	private static int THREADS_NUMBER = 100;
	private static ExecutorService exec = Executors.newFixedThreadPool(THREADS_NUMBER);
	
	public static void execute(Runnable command){
		exec.execute(command);
	}
	
	public static Channels execute(Manipulator m, PropertyContainer op) throws IOException {
		Channels ch = new Channels();
		execute(m.walk(op, ch));
		return ch;
	}

	public static Channels markExecute(Manipulator m, PropertyContainer op) throws IOException {
		Channels ch = new Channels();
		execute(m.markWalk(op, ch));
		return ch;
	}

	public static void execute(Manipulator m, PropertyContainer op, Channels ch) {
		execute(m.walk(op, ch));
	}
	
	public static void markExecute(Manipulator m, PropertyContainer op, Channels ch) {
		execute(m.markWalk(op, ch));
	}
	
	public static void shutdown() {
		exec.shutdown();
	}
}

@@ -826,36 +826,8 @@
 n;%0A%0A
-import java.io.IOException;%0A
 impo
@@ -922,128 +922,72 @@
 org.
-animotron.manipulator.Channels;%0Aimport org.animotron.manipulator.Manipulator;%0Aimport org.neo4j.graphdb.PropertyContainer
+jetlang.fibers.Fiber;%0Aimport org.jetlang.fibers.PoolFiberFactory
 ;%0A%0A/
@@ -1095,50 +1095,8 @@
 %7B%0A%09%0A
-%09private static int THREADS_NUMBER = 100;%0A
 %09pri
@@ -1147,11 +1147,12 @@
 .new
-Fix
+Cach
 edTh
@@ -1164,683 +1164,174 @@
 ool(
-THREADS_NUMBER);%0A%09%0A%09public static void execute(Runnable command)%7B%0A%09%09exec.execute(command);%0A%09%7D%0A%09%0A%09public static Channels execute(Manipulator m, PropertyContainer op) throws IOException %7B%0A%09%09Channels ch = new Channels();%0A%09%09execute(m.walk(op, ch));%0A%09%09return ch;%0A%09%7D%0A%0A%09public static Channels markExecute(Manipulator m, PropertyContainer op) throws IOException %7B%0A%09%09Channels ch = new Channels();%0A%09%09execute(m.markWalk(op, ch));%0A%09%09return ch;%0A%09%7D%0A%0A%09public static void execute(Manipulator m, PropertyContainer op, Channels ch) %7B%0A%09%09execute(m.walk(op, ch));%0A%09%7D%0A%09%0A%09public static void markExecute(Manipulator m, PropertyContainer op, Channels ch) %7B%0A%09%09execute(m.markWalk(op, ch));%0A%09%7D%0A%09%0A%09public
+);%0A%09private static PoolFiberFactory fact = new PoolFiberFactory(exec);%0A    %0A%09public Fiber getFiber() %7B%0A%09%09Fiber fiber =  fact.create();%0A%09%09return fiber;%0A%09%7D%0A%09%0A%09protected
  sta

recode to fiber