Re: Simultaneous destructors

Chris Jones <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
Chris Jones wrote:
> But wait, there's more! ;)
> 
> We could also *optimize away* the Moar/OnCancel round trip, assuming 
> that Necko already knows there's no more data available (i.e. response's 
> done or socket's closed) when it sends the first OnData() message. 
> Assuming this knowledge is available, then with the new message signature
> 
>   async OnData(bool isMoreData, ...);
> 

Actually, I forgot that IPDL already has linguistic support for this 
scenario (though it's not currently used).  You could write

   async OnData(...);

as you would otherwise, but then

   //...
   state NORMAL:
     send OnData goto SENT, STOPPED;

which means that sending OnData can affect either a transition to SENT 
*or* STOPPED, the C++ code must choose.  Since C++ must choose the next 
state, the IPDL compiler would generate a method like

   SendOnData(..., State next)

and in the small HTTP response case when Necko knows there are no more 
packets to deliver, it could invoke

   SendOnData(..., STOPPED)

after which the content process would *only* be allowed to send Cancel() 
then delete().

Another alternative would be to define a new |OnLastData()| message that 
transitions to STOPPED.

   async OnLastData(...);

   state NORMAL:
     send OnData goto SENT;
     send OnLastData goto STOPPED;

and send OnLastData() in the case above where you would have sent 
OnData(..., STOPPED).

Neither materially changes anything, but both of these ways feel a 
little cleaner to me.

Cheers,
Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.