On Sat, May 10, 2008 at 10:51 AM, Richard Jones <rich@annexia.org> wrote:
There are various restrictions on mutating the ancient data, which are
> As you cannot mutate anything that is ancient (since it might be
> concurrently
> accessed),
explained in the README. It is not true that ancient data is
completely immutable, just that you really need to understand what
you're doing in order to do it correctly.
There are additional
restrictions to mutating [any] data concurrently, but I didn't explain
those because they are obvious, and can be solved with standard
threading techniques (mutexes, etc.)..
I'm not sure what this means. I haven't tried to Marshal ancient
> you cannot mark or modify them in-place for ad-hoc marshalling or
> deep copying. Is that correct?
data, because ancient data can already be persisted, so marshaling it
doesn't make much sense.
'Deep copying' of ancient data can be done just like deep copying any
other OCaml value.
> Comparison does not mark (and thus does not work on cyclic structures).> Does it work on values in the ancient heap (I'm not talking of handlesYour use of 'value', 'handle' etc. is confusing me.
> here)?
I suggest you
take a look at how OCaml values are stored (eg. <caml/mlvalues.h> is a
good place to start).
Anyhow, the polymorphic primitives (like %compare) don't work, just
because they make the assumption that anything outside the normal
OCaml heap is incomparable
, but you can certainly write your own
comparison functions to replace those, eg. comparing
character-by-character for strings.
This has nothing to do with 'marking'.
> So it seems that adding a generic copy-out-of-the-ancient heap functionAs I said earlier, you can just copy values from the ancient heap as
> (which marks in a private area) would be worthwhile. Should not be too
> difficult.
you would any other value, eg. using { ... with ... } syntax or
Array.copy / String.copy etc.
Let's say this again. Values on the ancient heap look just like
values anywhere else in the program. You can pass them to functions,
print them out, add them up, do whatever else you would normally do,
with very few restrictions. The differences are:
- the polymorphic primitives don't work (so you can't compare or hash them)
- they don't get garbage collected
- you should be very careful about mutating them