Changeset da6732062b23f833e860da223901eeeb75eefaf7
- Timestamp:
- 07/05/08 13:22:09
(2 months ago)
- Author:
- Rémi Denis-Courmont <rdenis@simphalempin.com>
- git-committer:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1215256929 +0300
- git-parent:
[06e3b333dcadd50c4e335337ac852918331499ca]
- git-author:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1215256929 +0300
- Message:
vlc_object_alive: lock-less and inlined
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rc2c6729 |
rda67320 |
|
| 163 | 163 | __vlc_object_kill( VLC_OBJECT(a) ) |
|---|
| 164 | 164 | |
|---|
| 165 | | VLC_EXPORT( bool, __vlc_object_alive, ( vlc_object_t * ) ); |
|---|
| | 165 | static inline bool __vlc_object_alive (vlc_object_t *obj) |
|---|
| | 166 | { |
|---|
| | 167 | barrier (); |
|---|
| | 168 | return !obj->b_die; |
|---|
| | 169 | } |
|---|
| | 170 | |
|---|
| 166 | 171 | #define vlc_object_alive(a) \ |
|---|
| 167 | 172 | __vlc_object_alive( VLC_OBJECT(a) ) |
|---|
| rd4c651d |
rda67320 |
|
| 434 | 434 | vlc_mutex_init |
|---|
| 435 | 435 | vlc_mutex_init_recursive |
|---|
| 436 | | __vlc_object_alive |
|---|
| 437 | 436 | __vlc_object_attach |
|---|
| 438 | 437 | __vlc_object_create |
|---|
| rf2dcb78 |
rda67320 |
|
| 548 | 548 | |
|---|
| 549 | 549 | /** |
|---|
| 550 | | * Checks whether an object has been "killed". |
|---|
| 551 | | * The object lock must be held. |
|---|
| 552 | | * |
|---|
| 553 | | * Typical code for an object thread could be: |
|---|
| 554 | | * |
|---|
| 555 | | vlc_object_lock (self); |
|---|
| 556 | | ...initialization... |
|---|
| 557 | | while (vlc_object_alive (self)) |
|---|
| 558 | | { |
|---|
| 559 | | ...preprocessing... |
|---|
| 560 | | |
|---|
| 561 | | vlc_object_wait (self); |
|---|
| 562 | | |
|---|
| 563 | | ...postprocessing... |
|---|
| 564 | | } |
|---|
| 565 | | ...deinitialization... |
|---|
| 566 | | vlc_object_unlock (self); |
|---|
| 567 | | * |
|---|
| 568 | | * |
|---|
| 569 | | * @return true iff the object has not been killed yet |
|---|
| 570 | | */ |
|---|
| 571 | | bool __vlc_object_alive( vlc_object_t *obj ) |
|---|
| 572 | | { |
|---|
| 573 | | vlc_assert_locked( &(vlc_internals(obj)->lock) ); |
|---|
| 574 | | return !obj->b_die; |
|---|
| 575 | | } |
|---|
| 576 | | |
|---|
| 577 | | |
|---|
| 578 | | /** |
|---|
| 579 | 550 | * Signals an object for which the lock is held. |
|---|
| 580 | 551 | * At least one thread currently sleeping in vlc_object_wait() or |
|---|
| … | … | |
| 614 | 585 | |
|---|
| 615 | 586 | vlc_object_signal_unlocked( p_this ); |
|---|
| | 587 | /* This also serves as a memory barrier toward vlc_object_alive(): */ |
|---|
| 616 | 588 | vlc_object_unlock( p_this ); |
|---|
| 617 | 589 | } |
|---|