Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Till Varoquaux" <till.varoquaux@gmail.com>
To: "ocaml ml" <caml-list@inria.fr>
Subject: Implementing rollback channels with Ocamlnet
Date: Wed, 10 Jan 2007 18:08:57 +0100	[thread overview]
Message-ID: <9d3ec8300701100908m40f986dmafd9c41cb9fe06ba@mail.gmail.com> (raw)

I need to be able to backtrack while reading a stream. The way I tried
to do it was to build a new in_channel reading from the window of the
previous (buffered) channel.
Here's my current failed attempt:

open Netstream;;

exception BaseChannelAccess

class rollback_chan (is:in_obj_stream) : Netchannels.rec_in_channel=
object
 val mutable p_in=is#pos_in
 val mutable closed=false
 method close_in  () = ()
  method input dest dest_pos len =
  if (is#pos_in != p_in) then
   raise BaseChannelAccess;
  is#want(p_in+len);
  Netbuffer.blit is#window p_in dest dest_pos len;
  p_in <- p_in + len;
  len
end;;

let rollback_chan input=
  Netchannels.lift_in(`Rec (new rollback_chan(input)))

It doesn't work (at all). I must be getting something awfully wrong,
has anyone had more chance trying something similar?

Till


                 reply	other threads:[~2007-01-10 17:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d3ec8300701100908m40f986dmafd9c41cb9fe06ba@mail.gmail.com \
    --to=till.varoquaux@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox