2
fifo waitqueue for threads.(Multi-in, single out)
3
Copyright (C) 2000 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
14
#ifndef __THREADQUEUE_H
15
#define __THREADQUEUE_H
18
#include "abs_thread.h"
20
class WaitThreadEntry {
25
abs_thread_cond_t waitCond;
29
This class can be used as a general purpuse wrapper to
30
make C++ classes thread safe.
31
Mpeglib uses for every decoder a single thread which
32
reads from the input and write to one output type (video/audio)
33
To make the input and output classes thread safe you have
34
two solutions. First you can try to do it in every class
35
itsself, this is much work and needs understanding of
36
threads or you can use this wrapper class.
37
Normally you don't need two threads in one class, only
38
for the audio/video sync this is necessary, but for
39
the inputstream (file,http,..) this not necessary.
40
For the output this is the same.
41
This class offers two methods. waitForExclusiceAcess()
42
and releaseExlusiveAcess. Internally the thread who
43
calls waitFor.. in enqueued (if it does not get the exclusive
44
access) the thread who have the exclusive access calls
45
sometimes release.. with then pass the exclusive access
48
Because we access the input/output streams from different
49
threads. A user of mpeglib may want to set mpeg video
50
in fullscreen mode, this means two threads call
51
methods in the output classes including: closing windows,
52
resizing windows ... now this is safley possible when
53
the threadSafeInputStream / threadSafeoutputStream wrappers
54
are used, which forward the calls to the real classes.
59
abs_thread_mutex_t queueMut;
63
WaitThreadEntry** waitThreadEntries;
69
void waitForExclusiveAccess();
70
void releaseExclusiveAccess();