Make the decoder multi-threaded
This implements the basic infrastructure for multi-threaded
decoding of rects. However there is just one thread reading data
and one thread decoding it. More logic is needed to safely decode
multiple rects at the same time.
diff --git a/common/rfb/Decoder.h b/common/rfb/Decoder.h
index 4195a80..7286b41 100644
--- a/common/rfb/Decoder.h
+++ b/common/rfb/Decoder.h
@@ -38,9 +38,15 @@
// readRect() transfers data for the given rectangle from the
// InStream to the OutStream, possibly changing it along the way to
- // make it easier to decode.
+ // make it easier to decode. This function will always be called in
+ // a serial manner on the main thread.
virtual void readRect(const Rect& r, rdr::InStream* is,
const ConnParams& cp, rdr::OutStream* os)=0;
+
+ // These functions will be called from any of the worker threads.
+ // A lock will be held whilst these are called so it is safe to
+ // read and update internal state as necessary.
+
// decodeRect() decodes the given rectangle with data from the
// given buffer, onto the ModifiablePixelBuffer. The PixelFormat of
// the PixelBuffer might not match the ConnParams and it is up to
@@ -49,6 +55,7 @@
size_t buflen, const ConnParams& cp,
ModifiablePixelBuffer* pb)=0;
+ public:
static bool supported(int encoding);
static Decoder* createDecoder(int encoding);
};