00001 /* -*- c++ -*- */ 00002 /************************************************************************** 00003 Copyright (c) 2000-2001, Tony Garnock-Jones 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions are 00008 met: 00009 00010 * Redistributions of source code must retain the above copyright 00011 notice, this list of conditions and the following disclaimer. 00012 00013 * Redistributions in binary form must reproduce the above 00014 copyright notice, this list of conditions and the following 00015 disclaimer in the documentation and/or other materials provided 00016 with the distribution. 00017 00018 * Neither the names of the copyright holders nor the names of this 00019 software's contributors may be used to endorse or promote 00020 products derived from this software without specific prior 00021 written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 00027 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00028 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00029 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00030 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00031 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00032 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00033 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 **************************************************************************/ 00035 00036 #ifndef MPS_Transport_Fastmsg_H 00037 #define MPS_Transport_Fastmsg_H 00038 00039 #include <mps/mps.h> 00040 #include <fastmsg/Scheduler.h> 00041 00042 namespace MPS { 00043 00044 /** 00045 * Implements a Fastmsg-based Transport class for accessing and 00046 * serving MPS objects. 00047 * 00048 * Spawns a Scheduler Thread object for each object served by this 00049 * process across fastmsg. 00050 * 00051 * Since this uses fastmsg Scheduler Threads, you should call it 00052 * from SchedulerApp's appMain(). 00053 */ 00054 class FastmsgTransport: public MPS::Transport { 00055 private: 00056 static FastmsgTransport *instance; 00057 00058 Scheduler &sched; 00059 00060 FastmsgTransport(Scheduler &s); 00061 00062 protected: 00063 virtual ref<Connection> connectTo(Address const &connectionSpec); 00064 virtual string registerServer(Server *server, Address const &spec); 00065 virtual string deregisterServer(Server *server, Address const &spec); 00066 00067 public: 00068 static void initialise(Scheduler &s) { 00069 if (instance == 0) { 00070 instance = new FastmsgTransport(s); 00071 } 00072 } 00073 }; 00074 00075 } 00076 00077 #endif