/*______________________________________________________________________________ * * org.eidola.kernel.Engine * * Part of the Eidola Kernel Reference Implementation * See http://eidola.org for oodles of relevant fun! * *______________________________________________________________________________ * * Copyright 2000-2001 Paul Cantrell * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 2, as published by the * Free Software Foundation. See the file LICENSE.html for more information. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple * Place, Suite 330 / Boston, MA 02111-1307 / USA. *_______________________________________________________________________________ */ package org.eidola.kernel; import org.eidola.kernel.event.*; import org.eidola.util.ThreadFlock; /** Responsible for the large-scale organization of containers. This class is just a sketch until it becomes clearer exactly what sort of "large-scale organization" needs to happen, and which responsibilities fall on the UI vs. the kernel. Containers take an engine as a constructor argument, and add themselves on creation. This will almost certainly change.

Currently, the Engine does two things:

Open questions include:

@author Paul Cantrell @version [Development version] */ public class Engine { static public Engine getInstance() { if(defaultInstance == null) synchronized(Engine.class) { if(defaultInstance == null) (defaultInstance = new Engine()).start(); } return defaultInstance; } static private Engine defaultInstance; private Engine() { compiler = new Compiler(); compilerQ = new EventQueue("compilerQ"); compilerFlock = new ThreadFlock(compilerQ, 3); compilerFlock.setPriority(Thread.NORM_PRIORITY-2); compilerFlock.setDaemon(true); propagatorQ = new EventQueue("propagatorQ"); propagatorFlock = new ThreadFlock(propagatorQ, 3); propagatorFlock.setPriority(Thread.NORM_PRIORITY-1); propagatorFlock.setDaemon(true); } public void start() { compilerFlock.start(); propagatorFlock.start(); } public void add(Container container) { container.addListener(compiler, compilerQ); } public void remove(Container container) { container.removeListener(compiler); } public EventQueue getPropagatorQ() { return propagatorQ; } private Compiler compiler; private EventQueue compilerQ; private ThreadFlock compilerFlock; private EventQueue propagatorQ; private ThreadFlock propagatorFlock; }