Changeset 0adb6e3edef57a255a4c405fbecdce5f6f1dd03c

Show
Ignore:
Timestamp:
05/31/08 18:01:05 (3 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1212249665 +0300
git-parent:

[ca996f1791eab14f411419d4048dd501eda3f715]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1212248415 +0300
Message:

Have vlc_object_wait() to "return" void.

It was a misdesign to have it return b_die, due to the race condition
mentioned earlier.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_objects.h

    r73edaec r0adb6e3  
    163163    __vlc_object_unlock( VLC_OBJECT( obj ) ) 
    164164 
    165 VLC_EXPORT( bool, __vlc_object_wait, ( vlc_object_t * ) ); 
     165VLC_EXPORT( void, __vlc_object_wait, ( vlc_object_t * ) ); 
    166166#define vlc_object_wait( obj ) \ 
    167167    __vlc_object_wait( VLC_OBJECT( obj ) ) 
     
    202202bool __vlc_object_lock_and_wait( vlc_object_t *obj ) 
    203203{ 
    204     bool b = true
     204    bool b
    205205 
    206206    vlc_object_lock( obj ); 
    207     if( vlc_object_alive( obj ) ) 
    208         b = vlc_object_wait( obj ); 
     207    b = vlc_object_alive( obj ); 
     208    if( b ) 
     209    { 
     210        vlc_object_wait( obj ); 
     211        b = vlc_object_alive( obj ); 
     212    } 
    209213    vlc_object_unlock( obj ); 
    210214    return b; 
  • src/misc/objects.c

    rb39f83c r0adb6e3  
    528528/** 
    529529 * Waits for the object to be signaled (using vlc_object_signal()). 
    530  * If the object already has a signal pending, this function will return 
    531  * immediately. It is asserted that the caller holds the object lock. 
     530 * It is assumed that the caller has locked the object. This function will 
     531 * unlock the object, and lock it again before returning. 
     532 * If the object was signaled before the caller locked the object, it is 
     533 * undefined whether the signal will be lost or will wake the process. 
    532534 * 
    533535 * @return true if the object is dying and should terminate. 
    534536 */ 
    535 bool __vlc_object_wait( vlc_object_t *obj ) 
     537void __vlc_object_wait( vlc_object_t *obj ) 
    536538{ 
    537539    vlc_assert_locked( &obj->object_lock ); 
    538540    vlc_cond_wait( &obj->object_wait, &obj->object_lock ); 
    539     return obj->b_die; 
    540541} 
    541542 
     
    543544/** 
    544545 * Waits for the object to be signaled (using vlc_object_signal()), or for 
    545  * a timer to expire. 
    546  * If the object already has a signal pending, this function will return 
    547  * immediately. It is asserted that the caller holds the object lock. 
     546 * a timer to expire. It is asserted that the caller holds the object lock. 
    548547 * 
    549548 * @return negative if the object is dying and should terminate, 
     
    575574       ...preprocessing... 
    576575 
    577        if (vlc_object_wait (self)) 
    578            continue; 
     576       vlc_object_wait (self); 
    579577 
    580578       ...postprocessing... 
     
    595593/** 
    596594 * Signals an object for which the lock is held. 
     595 * At least one thread currently sleeping in vlc_object_wait() or 
     596 * vlc_object_timedwait() will wake up, assuming that there is at least one 
     597 * such thread in the first place. Otherwise, it is undefined whether the 
     598 * signal will be lost or will wake up one or more thread later. 
    597599 */ 
    598600void __vlc_object_signal_unlocked( vlc_object_t *obj )