[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Another kind of generic stream?

From: Greg Hudson <ghudson_at_mit.edu>
Date: 2000-12-24 13:57:41 CET

I am done converting the code base to generic streams and cleaning up
all the loose ends. Although I generated quite a mailbox-stuffer of
commits by doing it in bite-sized chunks (thank goodness for automated
tests), I think the resulting stream-related code is a lot more
concise and elegant than it used to be. If I broke anything, let me
know.

What do people think of a generic-stream-like type for text delta
window streams? Right now window handlers are passed around much like
read and write handlers were before, as pairs of parameters (one for
the handler, one for the baton). Although we don't use window streams
quite as often as byte streams, I think it still might be worth it to
make a data type to combine the handler and baton, as well as to
remove the inelegance of "call the window handler with NULL to end the
stream" by adding a separate close handler. The interface would look
something like:

        typedef struct whatever svn_txdelta_stream_t;
        typedef svn_error_t *(svn_txdelta_stream_push_handler_t)
                             (void *baton, svn_txdelta_window_t *window);
        typedef svn_error_t *(svn_txdelta_stream_pull_handler_t)
                             (void *baton, svn_txdelta_window_t **window);
        typedef svn_error_t *(svn_txdelta_stream_close_handler_t)(void *baton);

        svn_error_t *svn_txdelta_stream_push (svn_txdelta_stream_t *stream,
                                              svn_txdelta_window_t *window);
        svn_error_t *svn_txdelta_stream_pull (svn_txdelta_stream_t *stream,
                                              svn_txdelta_window_t **window);
        svn_error_t *svn_txdelta_stream_close (svn_txdelta_stream_t *stream);

        /* Maybe a single function to create which takes a pull, push,
           and close handler; it's hard to envision adding new
           operations to this kind of stream. */
        svn_txdelta_stream_t *svn_txdelta_stream_create (void *baton,
                                                         apr_pool_t *pool);
        void svn_txdelta_stream_set_pull (svn_txdelta_stream_t *stream,
                                          svn_txdelta_pull_handler_t handler);
        void svn_txdelta_stream_set_push (svn_txdelta_stream_t *stream,
                                          svn_txdelta_push_handler_t handler);
        void svn_txdelta_stream_set_close (svn_txdelta_stream_t *stream,
                                          svn_txdelta_close_handler_t handler);

(We already have a svn_txdelta_stream_t type returned by
svn_txdelta(), but it's not generic; it would be supplanted by a
pullable generic window stream.)

On the other hand, maybe this is more bulk than we really need. What
do people think?
Received on Sat Oct 21 14:36:18 2006

This is an archived mail posted to the Subversion Dev mailing list.