12 /* once unscheduled, the id cannot be used anymore */
13 while (id->state != unscheduled) {
17 ret = gstpoll (timeout);
20 if (id->state == unscheduled) {
21 /* id became unscheduled, read the fd and broadcast */
27 /* some other id got unlocked */
28 /* mark ourselves as EARLY, we release the lock and we could be
29 * unscheduled ourselves but we don't want the unscheduling thread
30 * to write on the fd */
32 /* wait until it reads the fd and signals us */
37 id->state = OK | EARLY;
48 /* if it's busy waiting in poll, write to the fd */
49 if (id->state == busy) {
52 /* when it leaves the poll, it'll detect the unscheduled. */
53 id->state = unscheduled;
68 /* once state changes to != OK, the id cannot be used anymore */
69 while (g_atomic_int_compare_and_exchange (&id->state, OK, BUSY) {
71 ret = gstpoll (timeout);
73 /* two things can happen here, either the entry is BUSY or UNSCHEDULED,
74 * first check if it was busy. */
75 if (g_atomic_int_compare_and_exchange (&id->state, BUSY, OK) {
76 /* we got unscheduled, see if it was because we timed out or some other
77 * id got unscheduled */
79 if (g_atomic_int_get (&waiters) > 0) {
81 /* some other id got unlocked */
82 /* wait until it reads the fd and signals us */
89 /* we timed out update the status. */
90 id->state = OK | EARLY;
94 else if (g_atomic_int_get (&id->state) == UNSCHEDULED) {
95 /* id became unscheduled, read the fd and broadcast */
98 g_atomic_int_dec (&waiters);
104 g_assert_not_reached ();
113 if (g_atomic_int_compare_and_exchange (&id->state, BUSY, UNSCHEDULED) {
114 /* if it's busy waiting in poll, write to the fd */
116 g_atomic_int_inc (&waiters)
121 /* was not waiting, just mark unscheduled */
122 g_atomic_int_set (id->state, UNSCHEDULED);