Changeset e7f887862f7d4b942d014d97b9bfe58aac298728
- 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
| re0784be |
re7f8878 |
|
| 112 | 112 | vlc_bool_t b_thread; |
|---|
| 113 | 113 | |
|---|
| | 114 | /* Objects thread synchronization */ |
|---|
| | 115 | int pipes[2]; |
|---|
| | 116 | |
|---|
| 114 | 117 | /* Objects management */ |
|---|
| 115 | 118 | unsigned i_refcount; |
|---|
| re0784be |
re7f8878 |
|
| 189 | 189 | vlc_cond_init( p_new, &p_new->object_wait ); |
|---|
| 190 | 190 | vlc_mutex_init( p_new, &p_priv->var_lock ); |
|---|
| | 191 | p_priv->pipes[0] = p_priv->pipes[1] = -1; |
|---|
| 191 | 192 | |
|---|
| 192 | 193 | if( i_type == VLC_OBJECT_GLOBAL ) |
|---|
| … | … | |
| 436 | 437 | vlc_mutex_destroy( &p_this->object_lock ); |
|---|
| 437 | 438 | 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] ); |
|---|
| 438 | 443 | |
|---|
| 439 | 444 | /* global is not dynamically allocated by vlc_object_create */ |
|---|
| … | … | |
| 466 | 471 | { |
|---|
| 467 | 472 | 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 | |
|---|
| 468 | 482 | vlc_cond_wait( &obj->object_wait, &obj->object_lock ); |
|---|
| 469 | 483 | return obj->b_die; |
|---|
| … | … | |
| 499 | 513 | { |
|---|
| 500 | 514 | 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 | |
|---|
| 501 | 520 | vlc_cond_signal( &obj->object_wait ); |
|---|
| 502 | 521 | } |
|---|
| … | … | |
| 516 | 535 | |
|---|
| 517 | 536 | 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 | |
|---|
| 518 | 545 | vlc_object_signal_unlocked( p_this ); |
|---|
| 519 | 546 | vlc_mutex_unlock( &p_this->object_lock ); |
|---|