bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>
Cc: bug-gnulib@gnu.org
Subject: Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)
Date: Sat, 10 Oct 2020 19:34:22 +0200	[thread overview]
Message-ID: <2702121.3zYb9QuFGE@omega> (raw)
In-Reply-To: <CAEYrNrTukScctpuXVAj9MCtaMei1zZE6qfFBOhOpYpS-0eJNag@mail.gmail.com>

Hi Marc,

> >   - +/* The public interface is documented in the file hamt.c.
> >
> >     This is not good. As a user of the module, I would want to read *only*
> >     hamt.h and know how to use the public interface. In other words, hamt.h
> >     should have the functions' comments.
> 
> I followed the example of the already existing "hash" module. But I
> can easily move the public comments into the header file.

Yes please. Here in Gnulib, we don't have a way to extract reference
documentation from the source code (we don't use doxygen or similar);
therefore a programmer who wants to use a Gnulib module must peruse
the .h file.

> >   - "Each
> >     updating operation returns a new hamt, which shares structure with
> >     the original one."
> >     So, after calling hamt_insert or hamt_delete, which function should I call
> >     to delete the original Hamt without affecting the new one? (In order to
> >     avoid accumulating pieces of old Hamts in memory.)
> 
> When you do, say,
> 
> new_hamt = hamt_insert (hamt, ...)
> 
> and new_hamt != hamt afterwards, you have to delete both hamt and
> new_hamt with hamt_free to free all the memory. After you have freed
> the first hamt, the second won't be affected.
> 
> >   - "The GL_HAMT_THREAD_SAFE flag is set if the implementation of hamts
> >     is thread-safe as long as two threads do not simultaneously access
> >     the same hamt."
> >     I don't understand this sentence. Isn't the guarantee that
> >     "is thread-safe as long as two threads do not simultaneously access
> >     the same hamt" trivial? And what you want to achieve through the use
> >     of _Atomic is that it is thread-safe *also* when two threads access
> >     the same hamt?
> 
> The guarantee is not trivial because two different hamts may share
> some structure.
> 
> So... assume you have a hamt. You do some operations on it (or you do
> hamt_copy) to get a new_hamt that shares structure. Now if thread 1
> works on hamt and thread 2 on new_hamt, it is safe when
> GL_HAMT_THREAD_SAFE is set.
> 
> If two threads access the same hamt, it is not guaranteed to be safe.
> If you need this, get an (extremely shallow) copy through hamt_copy
> first.

I see. Thanks. These explanation would make good comments.

Bruno



  reply	other threads:[~2020-10-10 17:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 21:07 [New module] Persistent Hash Array Mapped Tries (HAMTs) Marc Nieper-Wißkirchen
2020-10-10 14:35 ` Bruno Haible
2020-10-10 14:46   ` Marc Nieper-Wißkirchen
2020-10-10 17:34     ` Bruno Haible [this message]
2020-10-10 14:54 ` Bruno Haible
2020-10-10 15:01   ` Marc Nieper-Wißkirchen
2020-10-10 15:04     ` Marc Nieper-Wißkirchen
2020-10-10 17:41       ` Bruno Haible
2020-10-10 17:49         ` Marc Nieper-Wißkirchen
2020-10-10 18:19       ` Paul Eggert
2020-10-10 21:24         ` Marc Nieper-Wißkirchen
2020-10-10 21:46           ` Marc Nieper-Wißkirchen
2020-10-11  1:28             ` Bruno Haible
2020-10-11  8:20               ` Marc Nieper-Wißkirchen
2020-10-11  9:43                 ` Marc Nieper-Wißkirchen
2020-10-11 11:02                   ` HAMT iterator Bruno Haible
2020-10-11 11:08                     ` Marc Nieper-Wißkirchen
2020-10-11 12:04                       ` Bruno Haible
2020-10-11 12:25                         ` Marc Nieper-Wißkirchen
2020-10-11 13:52                           ` Bruno Haible
2020-10-11 12:14                       ` Bruno Haible
2020-10-11 12:22                         ` Marc Nieper-Wißkirchen
2020-10-11 10:29                 ` HAMT iterators Bruno Haible
2020-10-11 12:44                   ` Marc Nieper-Wißkirchen
2020-10-11 13:47                     ` Bruno Haible
2020-10-11 10:53                 ` out-of-memory handling Bruno Haible
2020-10-11 11:07                   ` Marc Nieper-Wißkirchen
2020-10-11 11:56                     ` Bruno Haible
2020-10-11 12:20                       ` Marc Nieper-Wißkirchen
2020-10-11 14:01                         ` HAMT for gl_set and gl_map Bruno Haible
2020-10-11 17:32                 ` [New module] Persistent Hash Array Mapped Tries (HAMTs) Marc Nieper-Wißkirchen
2020-10-11 18:22                   ` Draft #3 (with iterators) Marc Nieper-Wißkirchen
2020-10-11 19:09                     ` Bruno Haible
2020-10-12  6:06                       ` Non-opaque hamt type? Marc Nieper-Wißkirchen
2020-10-18 14:39                         ` Bruno Haible
2020-10-18 15:29                           ` Marc Nieper-Wißkirchen
2020-10-18 17:58                             ` Bruno Haible
2020-10-18 18:11                               ` Marc Nieper-Wißkirchen
2021-04-03  9:08                                 ` Marc Nieper-Wißkirchen
2021-04-03 10:26                                   ` Bruno Haible
2020-10-11 14:14             ` terminology Bruno Haible
2020-10-11 14:20               ` terminology Marc Nieper-Wißkirchen
2020-10-10 22:39         ` _Atomic Bruno Haible
2020-10-11 20:15           ` _Atomic Paul Eggert
2020-10-11 21:47             ` _Atomic Bruno Haible

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=2702121.3zYb9QuFGE@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=marc.nieper+gnu@gmail.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).