Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / docs / random / queue
1             thread 1                                         thread2
2
3                                                            // the queue is empty
4                                                            while (!queue->level_buffers) {
5                                                              STATUS("queue: %s U released lock\n");
6                                                              GST_OBJECT_UNLOCK (queue);
7
8   // thread1 is scheduled and puts a lot of buffers
9   // in the queue
10
11   // thread1 has put the last buffer on the queue
12   // here. A signal is going to be emited
13
14   tosignal = (queue->level_buffers >= 0);
15   queue->level_buffers++;
16
17   /* we can unlock now */
18   GST_OBJECT_UNLOCK (queue);
19
20   if (tosignal) {
21     g_mutex_lock (queue->emptylock);
22     g_cond_signal (queue->emptycond);
23     g_mutex_unlock (queue->emptylock);
24   }
25
26                                                              g_mutex_lock (queue->emptylock);
27                                                              // wait forever
28                                                              g_cond_wait (queue->emptycond, queue->emptylock);
29                                                              g_mutex_unlock (queue->emptylock);
30                                                              GST_OBJECT_LOCK (queue);
31                                                            }
32                                                            
33
34   // thread 1 will also wait forever because the
35   // queue is filled....
36
37
38