[vlc-devel] [PATCH 1/7] playlist/background_worker: introduce background-worker utility

Filip Roséen filip at atch.se
Fri Mar 24 04:05:51 CET 2017


Hi again,

On 2017-03-24 03:28, Filip Roséen wrote:

> This added utility will make it easier to handle a queue of tasks that
> is to be finished in the order received. It allows for users of the
> utility to focus on the end-goal instead of having to deal with
> synchronization issues in terms of task-queue handling.

I just noticed that I did not apply the appropriate *fixup*, before
doing `git format-patch` + `git send-email`, to fix a slight unit
issue in terms of the background-worker timeout, as well as allowing
backwards compatibility where a negative timeout is also accepted as a
value indicating that no timeout is set.

The attached patch is a revised implementation of the patch in which
this email is a reply to, but for easier reviewing the difference
between the two is that of the below:

    diff --git a/src/misc/background_worker.c b/src/misc/background_worker.c
    index 527509fb98..8009a601b1 100644
    --- a/src/misc/background_worker.c
    +++ b/src/misc/background_worker.c
    @@ -78,7 +78,7 @@ static void* Thread( void* data )
                     worker->head.id = item ? item->id : NULL;
    
                     if( item && item->timeout > 0 )
    -                    worker->head.deadline = mdate() + item->timeout;
    +                    worker->head.deadline = mdate() + item->timeout * 1000;
                 }
                 vlc_cond_broadcast( &worker->head.wait );
                 vlc_mutex_unlock( &worker->head.lock );
    @@ -191,7 +191,7 @@ int background_worker_Push( struct background_worker* worker, void* entity,
    
         item->id = id;
         item->entity = entity;
    -    item->timeout = timeout ? timeout*1000 : worker->conf.default_timeout;
    +    item->timeout = timeout > 0 ? timeout : worker->conf.default_timeout;
    
         vlc_mutex_lock( &worker->tail.lock );
         vlc_array_append( &worker->tail.data, item );
    diff --git a/src/misc/background_worker.h b/src/misc/background_worker.h
    index 8232c1d80a..1382781540 100644
    --- a/src/misc/background_worker.h
    +++ b/src/misc/background_worker.h
    @@ -23,9 +23,9 @@ struct background_worker_config {
         /**
          * Default timeout for completing a task
          *
    -     * If `0` a task can run indefinitely without being killed, whereas a value
    -     * other than `0` denotes the maximum number of milliseconds a task can run
    -     * before \ref pf_stop is called to kill it.
    +     * If less-than 0 a task can run indefinitely without being killed, whereas
    +     * a positive value denotes the maximum number of milliseconds a task can
    +     * run before \ref pf_stop is called to kill it.
          **/
         mtime_t default_timeout;

I apologize for the inconvenience.

Best Regards,\
Filip "in need of a smoke" Roséen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170324/0c03031a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-playlist-background_worker-introduce-background-work.patch
Type: text/x-diff
Size: 16672 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170324/0c03031a/attachment.patch>


More information about the vlc-devel mailing list