mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
docs/random/wtay/poll-timeout: Small tweaks.
Original commit message from CVS: * docs/random/wtay/poll-timeout: Small tweaks.
This commit is contained in:
parent
bb0cd4e7f1
commit
2488c97ebd
2 changed files with 19 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2008-11-13 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* docs/random/wtay/poll-timeout:
|
||||||
|
Small tweaks.
|
||||||
|
|
||||||
2008-11-13 Wim Taymans <wim.taymans@collabora.co.uk>
|
2008-11-13 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* tests/old/testsuite/caps/intersection.c: (main):
|
* tests/old/testsuite/caps/intersection.c: (main):
|
||||||
|
|
|
@ -76,12 +76,14 @@ waiting for id:
|
||||||
/* we got unscheduled, see if it was because we timed out or some other
|
/* we got unscheduled, see if it was because we timed out or some other
|
||||||
* id got unscheduled */
|
* id got unscheduled */
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
lock
|
if (g_atomic_int_get (&waiters) > 0) {
|
||||||
/* some other id got unlocked */
|
lock
|
||||||
/* wait until it reads the fd and signals us */
|
/* some other id got unlocked */
|
||||||
while (waiters)
|
/* wait until it reads the fd and signals us */
|
||||||
cond_wait ()
|
while (waiters)
|
||||||
unlock
|
cond_wait ()
|
||||||
|
unlock
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* we timed out update the status. */
|
/* we timed out update the status. */
|
||||||
|
@ -89,16 +91,18 @@ waiting for id:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_atomic_int_compare_and_exchange (&id->state, UNSCHEDULED, OK) {
|
else if (g_atomic_int_get (&id->state) == UNSCHEDULED) {
|
||||||
/* id became unscheduled, read the fd and broadcast */
|
/* id became unscheduled, read the fd and broadcast */
|
||||||
lock
|
lock
|
||||||
read (fd)
|
read (fd)
|
||||||
waiters--
|
g_atomic_int_dec (&waiters);
|
||||||
cond_broadcast ()
|
cond_broadcast ()
|
||||||
unlock
|
unlock
|
||||||
id->state = UNSCHEDULED;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return id->state;
|
return id->state;
|
||||||
|
@ -109,7 +113,7 @@ unschedule id:
|
||||||
if (g_atomic_int_compare_and_exchange (&id->state, BUSY, UNSCHEDULED) {
|
if (g_atomic_int_compare_and_exchange (&id->state, BUSY, UNSCHEDULED) {
|
||||||
/* if it's busy waiting in poll, write to the fd */
|
/* if it's busy waiting in poll, write to the fd */
|
||||||
lock
|
lock
|
||||||
waiters++
|
g_atomic_int_inc (&waiters)
|
||||||
write (fd)
|
write (fd)
|
||||||
unlock
|
unlock
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue