Changeset e7f887862f7d4b942d014d97b9bfe58aac298728

Show
Ignore:
Timestamp:
30/09/07 21:31:08 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1191180668 +0000
git-parent:

[7b4638dd18df095dbdb7e37a628f3f27cd10f587]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1191180668 +0000
Message:

Partial unfinished pipes conditional fallback for condition variables.
This would be necessary to rid the networking code of arbitrary timers (but it does not work yet).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/libvlc.h

    re0784be re7f8878  
    112112    vlc_bool_t      b_thread; 
    113113 
     114    /* Objects thread synchronization */ 
     115    int             pipes[2]; 
     116 
    114117    /* Objects management */ 
    115118    unsigned        i_refcount; 
  • src/misc/objects.c

    re0784be re7f8878  
    189189    vlc_cond_init( p_new, &p_new->object_wait ); 
    190190    vlc_mutex_init( p_new, &p_priv->var_lock ); 
     191    p_priv->pipes[0] = p_priv->pipes[1] = -1; 
    191192 
    192193    if( i_type == VLC_OBJECT_GLOBAL ) 
     
    436437    vlc_mutex_destroy( &p_this->object_lock ); 
    437438    vlc_cond_destroy( &p_this->object_wait ); 
     439    if( p_priv->pipes[0] != -1 ) 
     440        close( p_priv->pipes[0] ); 
     441    if( p_priv->pipes[1] != -1 ) 
     442        close( p_priv->pipes[1] ); 
    438443 
    439444    /* global is not dynamically allocated by vlc_object_create */ 
     
    466471{ 
    467472    vlc_assert_locked( &obj->object_lock ); 
     473 
     474    int fd = obj->p_internals->pipes[0]; 
     475    if( ( fd != -1 ) 
     476     && ( read( fd, &(char){ 0 }, 1 ) == 0 ) ) 
     477    { 
     478        close( fd ); 
     479        obj->p_internals->pipes[1] = -1; 
     480    }    
     481 
    468482    vlc_cond_wait( &obj->object_wait, &obj->object_lock ); 
    469483    return obj->b_die; 
     
    499513{ 
    500514    vlc_assert_locked( &obj->object_lock ); 
     515 
     516    int fd = obj->p_internals->pipes[1]; 
     517    if( fd != -1 ) 
     518        while( write( fd, &(char){ 0 }, 1 ) < 0 ); 
     519 
    501520    vlc_cond_signal( &obj->object_wait ); 
    502521} 
     
    516535 
    517536    p_this->b_die = VLC_TRUE; 
     537 
     538    int fd = p_this->p_internals->pipes[1]; 
     539    if( fd != -1 ) 
     540    { 
     541        close( fd ); 
     542        p_this->p_internals->pipes[1] = -1; 
     543    } 
     544 
    518545    vlc_object_signal_unlocked( p_this ); 
    519546    vlc_mutex_unlock( &p_this->object_lock );