conductor.H

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #ifndef ARCHON_RENDER_CONDUCTOR_H
00021 #define ARCHON_RENDER_CONDUCTOR_H
00022 
00023 #include <archon/util/condition.H>
00024 #include <archon/render/context.H>
00025 
00026 namespace Archon
00027 {
00028   namespace Render
00029   {
00067     struct Conductor: RefObjectBase
00068     {
00069       static Ref<Conductor> create()
00070       {
00071         return new Conductor;
00072       }
00073 
00074       Ref<Pipe> addPipe(Ref<Display::Visual>, bool direct = true);
00075 
00079       void render();
00080 
00081       Ref<Pipe> getMasterPipe() const
00082       {
00083         Mutex::Lock l(syncMutex);
00084         return masterPipe;
00085       }
00086 
00092       void terminate();
00093 
00094     private:
00095       Conductor();
00096 
00101       Mutex syncMutex;
00102 
00103       friend struct Pipe;
00104 
00105       void addWindow(Ref<Display::Window>, Ref<Pipe>);
00106 
00107       void slaveThread(unsigned index);
00108 
00109       vector<pair<Ref<Display::Window>, Ref<Pipe> > > windows;
00110 
00111       struct Slave
00112       {
00113         Ref<Pipe> pipe;
00114         Ref<Thread> thread;
00115         bool hold;
00116 
00117         Slave(Ref<Pipe> pipe, Ref<Thread> thread);
00118       };
00119 
00120       Ref<Pipe> masterPipe;
00121       vector<Slave> slaves;
00122       unsigned unfinishedSlaves;
00123       Condition proceed, slaveFinished;
00124     };
00125   }
00126 }
00127 
00128 #endif // ARCHON_RENDER_CONDUCTOR_H

Generated on Sun Jul 30 22:55:43 2006 for Archon by  doxygen 1.4.4