W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2010

[whatwg] WebSocket bufferedAmount includes overhead or not

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 31 Mar 2010 18:16:56 -0400
Message-ID: <4BB3C9D8.8010100@mit.edu>
On 3/31/10 2:38 AM, Jonas Sicking wrote:
> I would have expected bufferedAmount to only change as a result of an
> event being posted to the main event loop. We generally try to avoid
> "racy" variables since people don't expect them. Consider for example
>
> if (ws.bufferedAmount>  X) {
>    setUpSomeState();
> }
>
> try {
>    doOtherThings();
> }
> finally {
>    if (ws.bufferedAmount>  X) {
>      cleanUpState();
>    }
> }
>
> I'd imagine most JS developers to expect the cleanup to always happen
> if the setup did.

Sure, but do they expect the cleanup to happen if the setup did not if 
doOtherThings tried to send() stuff?

More to the point, is send() allowed to actually send anything when 
called, or does it have to buffer it all until the next time you get to 
the event loop?

-Boris
Received on Wednesday, 31 March 2010 15:16:56 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:22 UTC