Dear Wacek,
What you observe is most probably a bug in the engine. However, I also
found something not so cool in your procedure Post:
On Thu, Oct 9, 2008 at 3:31 PM, Wacek Kusnierczyk <
[EMAIL PROTECTED]> wrote:
> functor
> import Connection Pickle System
> define
> Messages
> MessagePort = {Port.new Messages}
> proc {Post post(In Out)}
> {Send MessagePort In}
> Out = success end in
> {Pickle.save {Connection.offerUnlimited Post} post}
> for Message in Messages do {System.show Message} end
> end
Waiting on Out after calling {Post post(X Out)} can be misleading. Indeed,
the operation Send is *asynchronous*, which means that Out can be bound to
success even if the message is not sent yet. In fact, in most cases, Out
will be bound *before* the message is actually delivered on the port's
stream.
In your case, it means that the client may exit before its distribution
layer had the time to send the message...
functor
> import Connection Pickle Application System
> define
> Post = {Connection.take {Pickle.load post}}
> Response = {Post post(hello $)} in
> {Wait Response}
> {System.show Response}
> {Application.exit 0}
> end
If you want the variable Out to behave like an acknowledgement, it should be
bound on the server side. Here is how you can redefine Post:
local MAs in
P={NewPort MAs}
Ms = thread {Map MAs fun {$ M#Ack} Ack=unit M end} end
proc {Post post(M Ack)} {Send M#Ack} end
end
You can also use Port.sendRecv to send a pair message-response. Its
implementation is optimized in Mozart 1.4.0.
I don't know whether you can work around the bug with that trick, but you
can give it a try...
Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users