On Thu, Aug 08, 2002 at 03:13:37PM +0200, G?ran Thyni wrote:
> 
> On Wed, Aug 07, 2002 at 10:10:29PM +0200, Oskar Sandberg wrote:
<>
> > In order for the Buffer implementation to do it's job, it needs to
> > support "sliding locks". That is to say: if somebody starts reading a
> > buffer while is being written to, you need to make sure that the reader
> > can read as much as possible, but that it stays behind the writer by
> > wait()ing when it caches up.
> 
> One approach would be the simplistic way to get
> a atomic write:
> - Write to tmp-file then "File.rename()"
> 
> at least on unix an open file is refer to by inodes so
> as long as the file is already open you can read until
> you close it, changes in the directory has no effect.
> 
> Still it may be best (but not necessary) to block multiple
> writer.

I don't understand how this will fix anything. What we need is
behavior like "tail -f" to the readers - when they catch up to the writer
they should block until something more gets added. But this also needs to
work if the file is being written to for a second or n-th time - readers
that started from the begining after the writer need to stay behind it.

> Problem with this approach?
> What about non-unix systems, anyone?
> 
> > It also needs to do vice versa: if somebody
> > starts overwriting a buffer while it is being read from, you need to make
> > sure that the writer can write as much as possible but then wait()s when
> > it caches up with the reader.
> 
> Do we ever rewrite keys? Not CHK keys?

We use CircularBuffers - when data is considered to be to large to
cache, it sends it to a circular buffer meaning that the when the writer
reaches the end of the buffer, it starts over (but makes sure it does
not "lap" the position of any reader that already started reading). The
"lapping" code is already implemented in CircularBuffer.java, all you
need to do is make sure that the writer cannot pass readers that are
ahead of it (and vice versa) in a Buffer.

> I will have to read up on the key type and their function.

This has nothing to do with keytypes.

-- 

Oskar Sandberg
oskar at freenetproject.org

_______________________________________________
devl mailing list
devl at freenetproject.org
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to