Changeset 0adb6e3edef57a255a4c405fbecdce5f6f1dd03c
- 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
| r73edaec |
r0adb6e3 |
|
| 163 | 163 | __vlc_object_unlock( VLC_OBJECT( obj ) ) |
|---|
| 164 | 164 | |
|---|
| 165 | | VLC_EXPORT( bool, __vlc_object_wait, ( vlc_object_t * ) ); |
|---|
| | 165 | VLC_EXPORT( void, __vlc_object_wait, ( vlc_object_t * ) ); |
|---|
| 166 | 166 | #define vlc_object_wait( obj ) \ |
|---|
| 167 | 167 | __vlc_object_wait( VLC_OBJECT( obj ) ) |
|---|
| … | … | |
| 202 | 202 | bool __vlc_object_lock_and_wait( vlc_object_t *obj ) |
|---|
| 203 | 203 | { |
|---|
| 204 | | bool b = true; |
|---|
| | 204 | bool b; |
|---|
| 205 | 205 | |
|---|
| 206 | 206 | 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 | } |
|---|
| 209 | 213 | vlc_object_unlock( obj ); |
|---|
| 210 | 214 | return b; |
|---|
| rb39f83c |
r0adb6e3 |
|
| 528 | 528 | /** |
|---|
| 529 | 529 | * 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. |
|---|
| 532 | 534 | * |
|---|
| 533 | 535 | * @return true if the object is dying and should terminate. |
|---|
| 534 | 536 | */ |
|---|
| 535 | | bool __vlc_object_wait( vlc_object_t *obj ) |
|---|
| | 537 | void __vlc_object_wait( vlc_object_t *obj ) |
|---|
| 536 | 538 | { |
|---|
| 537 | 539 | vlc_assert_locked( &obj->object_lock ); |
|---|
| 538 | 540 | vlc_cond_wait( &obj->object_wait, &obj->object_lock ); |
|---|
| 539 | | return obj->b_die; |
|---|
| 540 | 541 | } |
|---|
| 541 | 542 | |
|---|
| … | … | |
| 543 | 544 | /** |
|---|
| 544 | 545 | * 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. |
|---|
| 548 | 547 | * |
|---|
| 549 | 548 | * @return negative if the object is dying and should terminate, |
|---|
| … | … | |
| 575 | 574 | ...preprocessing... |
|---|
| 576 | 575 | |
|---|
| 577 | | if (vlc_object_wait (self)) |
|---|
| 578 | | continue; |
|---|
| | 576 | vlc_object_wait (self); |
|---|
| 579 | 577 | |
|---|
| 580 | 578 | ...postprocessing... |
|---|
| … | … | |
| 595 | 593 | /** |
|---|
| 596 | 594 | * 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. |
|---|
| 597 | 599 | */ |
|---|
| 598 | 600 | void __vlc_object_signal_unlocked( vlc_object_t *obj ) |
|---|