<html><head></head><body>Hi,<br><br>That's awful design IMO. A pool should be a self-standing object and the means to synchronise a threaded object are an implementation detail thereof, not somethign that should leak out.<br><br>Ideally the pool cancellation hack should be removed, as Thomas and you claimed that there are no deadlocks anymore. But if it needs to stay, there are no reasons to change it.<br><br><div class="gmail_quote">Le 27 juillet 2020 16:45:24 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">So we can use an external one.<hr> src/misc/picture_pool.c | 26 ++++++++++++++------------<br> 1 file changed, 14 insertions(+), 12 deletions(-)<br><br>diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c<br>index 2605b37454f..82b49ebd4c4 100644<br>--- a/src/misc/picture_pool.c<br>+++ b/src/misc/picture_pool.c<br>@@ -40,6 +40,7 @@ static_assert ((POOL_MAX & (POOL_MAX - 1)) == 0, "Not a power of two");<br> <br> struct picture_pool_t {<br> vlc_cancelable cancel;<br>+ vlc_cancelable *cancelable;<br> <br> unsigned long long available;<br> atomic_ushort refs;<br>@@ -73,11 +74,11 @@ static void picture_pool_ReleaseClone(picture_t *clone)<br> <br> picture_Release(picture);<br> <br>- vlc_mutex_lock(&pool->cancel.lock);<br>+ vlc_mutex_lock(&pool->cancelable->lock);<br> assert(!(pool->available & (1ULL << offset)));<br> pool->available |= 1ULL << offset;<br>- vlc_cond_signal(&pool->cancel.wait);<br>- vlc_mutex_unlock(&pool->cancel.lock);<br>+ vlc_cond_signal(&pool->cancelable->wait);<br>+ vlc_mutex_unlock(&pool->cancelable->lock);<br> <br> picture_pool_Destroy(pool);<br> }<br>@@ -106,6 +107,7 @@ picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)<br> return NULL;<br> <br> vlc_cancelable_Init( &pool->cancel );<br>+ pool->cancelable = &pool->cancel;<br> <br> if (count == POOL_MAX)<br> pool->available = ~0ULL;<br>@@ -168,7 +170,7 @@ picture_t *picture_pool_Get(picture_pool_t *pool)<br> {<br> unsigned long long available;<br> <br>- vlc_mutex_lock(&pool->cancel.lock);<br>+ vlc_mutex_lock(&pool->cancelable->lock);<br> assert(pool->refs > 0);<br> available = pool->available;<br> <br>@@ -176,11 +178,11 @@ picture_t *picture_pool_Get(picture_pool_t *pool)<br> {<br> int i = ctz(available);<br> <br>- if (unlikely(pool->cancel.canceled))<br>+ if (unlikely(pool->cancelable->canceled))<br> break;<br> <br> pool->available &= ~(1ULL << i);<br>- vlc_mutex_unlock(&pool->cancel.lock);<br>+ vlc_mutex_unlock(&pool->cancelable->lock);<br> available &= ~(1ULL << i);<br> <br> picture_t *clone = picture_pool_ClonePicture(pool, i);<br>@@ -191,27 +193,27 @@ picture_t *picture_pool_Get(picture_pool_t *pool)<br> return clone;<br> }<br> <br>- vlc_mutex_unlock(&pool->cancel.lock);<br>+ vlc_mutex_unlock(&pool->cancelable->lock);<br> return NULL;<br> }<br> <br> picture_t *picture_pool_Wait(picture_pool_t *pool)<br> {<br>- vlc_mutex_lock(&pool->cancel.lock);<br>+ vlc_mutex_lock(&pool->cancelable->lock);<br> assert(pool->refs > 0);<br> <br> while (pool->available == 0)<br> {<br>- if (!vlc_cancelable_Wait(&pool->cancel))<br>+ if (!vlc_cancelable_Wait(pool->cancelable))<br> {<br>- vlc_mutex_unlock(&pool->cancel.lock);<br>+ vlc_mutex_unlock(&pool->cancelable->lock);<br> return NULL;<br> }<br> }<br> <br> int i = ctz(pool->available);<br> pool->available &= ~(1ULL << i);<br>- vlc_mutex_unlock(&pool->cancel.lock);<br>+ vlc_mutex_unlock(&pool->cancelable->lock);<br> <br> picture_t *clone = picture_pool_ClonePicture(pool, i);<br> if (clone != NULL) {<br>@@ -224,7 +226,7 @@ picture_t *picture_pool_Wait(picture_pool_t *pool)<br> void picture_pool_Cancel(picture_pool_t *pool, bool canceled)<br> {<br> assert(pool->refs > 0);<br>- vlc_cancelable_SetCanceled( &pool->cancel, canceled );<br>+ vlc_cancelable_SetCanceled( pool->cancelable, canceled );<br> }<br> <br> unsigned picture_pool_GetSize(const picture_pool_t *pool)</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>