[MUD-Dev] Re: PDMud thread summary

James Wilson jwilson at rochester.rr.com
Sun Oct 25 15:35:52 CET 1998


On Sun, 25 Oct 1998, Niklas Elmqvist wrote:

>class Module {
>	ModuleID mID;
>	..
>public:
>	Module(Core *hCore); 	// Constructor
>	~Module();
>	..
>	// The following are quite empty and to be overridden
>	virtual void Init(..);
>	virtual bool HandleEvent(..); 
>	..
>}
>// Pipe abstract class: no functionality
>class Pipe {
>private:
>	ModuleID *hNode1, *hNode2;
>public:
>	..
>	virtual void Send(ModuleID hSrc, ModuleID hDst, Message *hMsg);
>	virtual Msg *Recv(ModuleID hCurr); 
>	..
>}
>(Not satisified about this, but am pressed for time.)

>class CallPipe : public Pipe {
>private:
>	FunctionPtr *hFun1, *hFun2;
>public:
>	..
>	virtual void Send(ModuleID hSrc, ModuleID hDst, Message *hMsg);
>	virtual void Recv(..)
>	..
>}
>

[other kinds of Pipes snipped]

thanks for the example, it made things much clearer. the pattern
here is asynchronous message-passing, as found in, for instance, 
PVM, which is well-suited to highly decoupled parallel systems. 
If this is what people want, PVM already does this beautifully and
there's even a distributed FS for it. However, message-passing like 
this adds considerable programming complexity to simple operations. 
Every function call into other modules has to be done as Send and Recv 
pairs, where the next Message Recv'd isn't necessarily what you wanted:

/* try to get object 'foo' */

g_mainbus->Send (module_a, DB_MODULE, /* deliver foo or else! */);
Message *gotfoo = g_mainbus->Recv (module_a);

/* simultaneously, in some other meddling module... */

g_mainbus->Send (module_meddler, module_a, /* you go to hell! */);

so, back in module_a, we get 'you go to hell!' instead of 'foo'.
Checking this on EVERY FUNCTION CALL would get quite tedious
and add a performance hit. Moreover it's more prone to breakage
by newbie module-programmers for whom parallel systems are
mysterious.

I fully agree that abstractions are important. This seems like rather
an extreme way to do it though, which to me is only really justified
in a distributed system.

James




More information about the mud-dev-archive mailing list