A channel provides no way to specify whether we stopped sending data
because of an error or because there is no more data.
Therefore, make Odb.ForEach() take a callback with which the user is free to
do whatever they need, letting us return en error.
The library stores error information in thread-local storage, which
means we need to make sure that the Go runtime doesn't switch OS
threads between the time we call a function and th time we attempt to
retrieve the error information.
The interface to these streams should be what you expect from Go, and
both have Write and Close functions so they implement
Reader/ReadCloser and Write/WriteCloser respectively.
Provide a manual way of freeing objects, but set finalizers for them
in case the user does not want to worry about memory management, which
would be useful for commits or trees, which sare typically small.
When the objects are freed manually, the finalizer is unset to avoid
double-freeing, mimicking what the go runtime does.