gstreamer/docs/random/queue
Andy Wingo 44c548b205 *.*: Ran scripts/update-macros. Oh yes. gst/gstobject.h (GST_OBJECT_GET_LOCK, GST_OBJECT_LOCK)
Original commit message from CVS:
2005-11-21  Andy Wingo  <wingo@pobox.com>

* *.h:
* *.c: Ran scripts/update-macros. Oh yes.

* gst/gstobject.h (GST_OBJECT_GET_LOCK, GST_OBJECT_LOCK)
(GST_OBJECT_TRYLOCK, GST_OBJECT_UNLOCK): Renamed from
GST_GET_LOCK, etc.

* scripts/update-macros: New script. Run it on your files to
change GST_LOCK to GST_OBJECT_LOCK, and the same for UNLOCK as
well.
2005-11-21 16:34:26 +00:00

39 lines
1.4 KiB
Plaintext

thread 1 thread2
// the queue is empty
while (!queue->level_buffers) {
STATUS("queue: %s U released lock\n");
GST_OBJECT_UNLOCK (queue);
// thread1 is scheduled and puts a lot of buffers
// in the queue
// thread1 has put the last buffer on the queue
// here. A signal is going to be emited
tosignal = (queue->level_buffers >= 0);
queue->level_buffers++;
/* we can unlock now */
GST_OBJECT_UNLOCK (queue);
if (tosignal) {
g_mutex_lock (queue->emptylock);
g_cond_signal (queue->emptycond);
g_mutex_unlock (queue->emptylock);
}
g_mutex_lock (queue->emptylock);
// wait forever
g_cond_wait (queue->emptycond, queue->emptylock);
g_mutex_unlock (queue->emptylock);
GST_OBJECT_LOCK (queue);
}
// thread 1 will also wait forever because the
// queue is filled....