[vlc-devel] commit: block_FifoEmpty: reduce contention scope ( Rémi Denis-Courmont )
git version control
git at videolan.org
Mon Nov 16 19:13:30 CET 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Nov 16 19:56:07 2009 +0200| [211199d83abefc47ff9620c02e1c08ba46581819] | committer: Rémi Denis-Courmont
block_FifoEmpty: reduce contention scope
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=211199d83abefc47ff9620c02e1c08ba46581819
---
src/misc/block.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/misc/block.c b/src/misc/block.c
index 43b3ec4..18f7b03 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -508,23 +508,27 @@ void block_FifoRelease( block_fifo_t *p_fifo )
void block_FifoEmpty( block_fifo_t *p_fifo )
{
- block_t *b;
+ block_t *block;
vlc_mutex_lock( &p_fifo->lock );
- for( b = p_fifo->p_first; b != NULL; )
+ block = p_fifo->p_first;
+ if (block != NULL)
{
- block_t *p_next;
-
- p_next = b->p_next;
- block_Release( b );
- b = p_next;
+ p_fifo->i_depth = p_fifo->i_size = 0;
+ p_fifo->p_first = NULL;
+ p_fifo->pp_last = &p_fifo->p_first;
}
-
- p_fifo->i_depth = p_fifo->i_size = 0;
- p_fifo->p_first = NULL;
- p_fifo->pp_last = &p_fifo->p_first;
vlc_cond_broadcast( &p_fifo->wait_room );
vlc_mutex_unlock( &p_fifo->lock );
+
+ while (block != NULL)
+ {
+ block_t *buf;
+
+ buf = block->p_next;
+ block_Release (block);
+ block = buf;
+ }
}
/**
More information about the vlc-devel
mailing list