Raphael Collet wrote:
> 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.
>
of course; as i said, this is a simplified code, and certainly it's not
perfect. the point is, even if i add a delay statement here or there,
so that the server does actually receive the message through the port
(which can be seen by the server's printing the message out), the server
does start spinning after the client terminates.
in the other version i posted recently (in reply to some other post),
the client must have waited for the server to answer through the
client's port, so the problem above disappears, as the client cannot
terminate before it gets an answer. yet still there is the same
spinning behaviour of the server.
> 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...
>
i can try this pattern, but since the solution with the server sending a
message back through the client's port does not help, i'd expect this
one not to work either. i'll check it and let you know.
thanks for the reply.
vQ
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users