[ccan] [PATCH 4/4] agar: Re-entrant Abstract Graph Algorithms

David Gibson david at gibson.dropbear.id.au
Wed Jul 9 21:17:13 EST 2014


On Tue, Jul 08, 2014 at 08:52:37PM +0930, Paul 'Rusty' Russell wrote:
> David Gibson <david at gibson.dropbear.id.au> writes:
> > The graph algorithms in the aga module require some node-local storage.
> > This means that the calling code:
> >     a) Needs to actually allocate memory per node.  That may or may not
> >        be natural depending on its internal representation.
> >     b) Multiple algorithms can't run at once (easily), since they all need
> >        to use the aga_node structures.
> >
> > This patch adds a new "agar" module which uses the aga module to provide
> > versions without those restrictions, by allocating per-node storage itself
> > for each run, and associating those with the caller's representation of
> > nodes via a hash table.
> 
> Bonus points for the cute name :)
> 
> I've thought about a 'tag' module which would provide dynamic struct
> fields (ie. allow you to tag arbitrary memory).  This is essentially
> what you've implemented.

Roughly yes.

One other possibility for this is to allow cmp and hash callbacks,
rather than hashing a pointer.  That would allow further pushing the
notion that the caller doesn't have to even instantiate the nodes
itself, if they can just be deduced on the fly.

But it's clunkier to use, so it's probably not worth it.

> You could almost roll this into ccan/aga if you allowed for callbacks
> on aga_start and aga_finish?

Hm, maybe.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20140709/1b6433b3/attachment.sig>


More information about the ccan mailing list