Hey Michael,

2008/11/18 Michael Sørensen Loft <[EMAIL PROTECTED]>:
>> I suggest that we make a build configuration option for the
>> wthttpd that allows the choice between either scenario
>> (transmitting a buffer using async I/O versus directly
>> streaming using sync I/O). The latter option would then be
>> more suitable for embedded systems.
>
> I don't know enough about how wthtpd works to tell if this would solve the 
> problem. Would this cause my resource to be asked for more data?

No, you would implement your resource simply writing everything to it in one go.
But, memory usage would be limited to an internal I/O buffer, and the
write() would block while the buffer is being transmitted.

So, during this synchronous I/O, you would keep using the same thread
until the entire resource is streamed to the browser.

> What I need is something like this, described in pseudo code:
>
> DataStream stream;
> Resource resource = getResourceBasedOnWebRequest(url);
> while (resource.hasMoreData())
> {
>  resource.fillData(stream);
>  sendDataToBrowser(stream);
> }

Well, this pseudo code also suggest synchronous code -- but here you
explicitly determine the size of the chunks.

Instead, an asynchronous way of doing would be in pseudo code:

void streamNextPart() {
  if (resource.hasMoreData()) {
     // .. get next data chunk
     ...

     // send to browser, and supply a callback to be called when done
     sendAsyncToBrowser(..., &streamNextPart);
  }
 }

The latter approach has the benefit of being entirely scalable in all
situations, but is more complicated, and for an embedded platform this
scalability (towards many concurrent threads) is not an immediate
concern.

Both solutions solve your problem, imho, and so we will pick one.

Regards,
koen

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to