[whatwg] WebSocket bufferedAmount includes overhead or not

Boris Zbarsky bzbarsky at MIT.EDU
Wed Mar 31 15:16:56 PDT 2010


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



More information about the whatwg mailing list