I got an answer from Günter, that I first thought solved my problem. But then I realized that I forgot an importantant part in my explanation.
Thread1 should always do it's work in this server, that is, parse and authorize the stream.
But thread two has the choice to either parse and act on the stream, or just send the stream to another server...
Günters suggestion, which was perfect for the one server scenario:
Hi Björn,
I have followed the discussion in the forum regarding this issue.
From the limited information I know about your problem, I wonder why you need two separate threads parsing the same XML file simultaneously.
Given that you cannot parse in parallel anyway (the second thread can only parse the buffer's content after the first has finished), why not simply create a special ContentHandler that forwards all events to the two different ContentHandler instances you're going to use, like:
class MultiContentHandler: public Poco::XML::ContentHandler
{
public:
MultiContentHandler(ContentHandler* pFirst, ContentHandler* pSecond):
_pFirst(pFirst),
_pSecond(pSecond)
{
}
void startDocument()
{
_pFirst->startDocument();
_pSecond->startDocument();
}
// ...
private:
Poco::XML::ContentHandler* _pFirst;
Poco::XML::ContentHandler* _pSecond;
};
This way you only need one parsing thread, but can feed two (or even more) ContentHandler's with the same content.
Just my two cents...
Günter