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

Re: [PATCH] add limit argument to svn_repos_history

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2007-07-26 04:41:25 CEST

Daniel Rall wrote:
>
> On Jul 25, 2007, at 12:26 PM, David Glasser wrote:
>
>> On 7/25/07, Daniel Rall <dlr@finemaltcoding.com> wrote:
>>>
>>> On Jul 25, 2007, at 9:53 AM, C. Michael Pilato wrote:
>>> > 3. don't rev svn_repos_history(), and use callback cancellation
>>> > exclusively to control continuation of the function.
>>>
>>> I like option #3, , along with an svn_cancel_func_t implementation
>>> which treats its baton as a limit and count parameter.
>>
>> +1
>
> Turns out Mike was really talking about having ANY callback be able to
> return an error code (a la SVN_ERR_CANCELLED) signifying that the
> callback should not be invoked again. Invokers of the callback would
> catch this error, clear it, and return SVN_NO_ERROR.
>
> David pointed out that while this works for most cases, that sometimes
> you want to invoke a cancellation callback more often than you would a
> function callback.

Right. Which is why I was *not* also advocating removing cancel_funcs from
functions that take them. I'm talking about supporting the likes of this:

   svn_error_t callback(baton)
     {
        /* Do something. */
        do_stuff();

        /* If our baton is setup with a limit and we've reached
           it, signal the callback driver to stop calling us. */
        if (baton.limit && (++baton.count > baton.limit))
          return SVN_ERR_CANCELLED;

        return SVN_NO_ERROR;
     }

   svn_error_t do_something(callback, baton, cancel_func, cancel_baton)
     {
       while (some_cond)
         {
           /* Do something that takes a while. See if user wants to cancel
              afterwards. */
           do_other_stuff();
           SVN_ERR(cancel_func, cancel_baton);

           /* Do something else that takes a while. See if user wants
              to cancel afterwards. */
           do_still_more_stuff();
           SVN_ERR(cancel_func, cancel_baton);

           /* Call the main callback, which might tell us to stop
              calling it. */
           err = callback(baton)
           if (err && err->apr_err == SVN_ERR_CANCELLED)
             {
               svn_error_clear(err);
               return SVN_NO_ERROR;
             }
           SVN_ERR(err);
         }

       return SVN_NO_ERROR;
     }

-- 
C. Michael Pilato <cmpilato@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Received on Thu Jul 26 04:40:17 2007

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.