Streams buffers and threads oh my

Please post support and help requests here.
Posts: 1
Joined: 21 Feb 2009, 15:42

Streams buffers and threads oh my

Postby Jon » 21 Feb 2009, 15:48

can someone please explain how to use the "BasicBufferedBidirectionalStreamBuf" object in poco?
how do I use the function readFromDevice()? and if someone could explain about the required fields in the constructor I would be grateful.

I searched for a Poco object similar to countDownLatch in java but I'm not sure which is which.

thanks in advance.

Posts: 1268
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Streams buffers and threads oh my

Postby guenter » 25 Feb 2009, 07:41

A look at the implementation of FileStream in Foundation or SocketStream in the Net library should make it quite clear how to use BufferedBidirectionalStreamBuf. Basically, you pass the size of the internal buffer, as well as the mode (input, output or both) to the constructor. readFromDevice() should simply try to read the given number of bytes from the underlying device and place it into the given buffer. Reading fewer bytes than requested is okay.

Regarding CountDownLatch, I am afraid we don't have this in POCO. What comes closes, though, is the Poco::Event class. You should be able to build a CountDownLatch on top of that by combining a Poco::Event (manual reset) with a counter and a Mutex to protect the counter.

Return to “Support”

Who is online

Users browsing this forum: No registered users and 6 guests