CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006
    Posts
    32

    need help with circularbuffer warkmark level

    I am treating a circular buffer like a buffer.

    I have a situation that can occur in my design. I could receive 384 bytes into the circular buffer, and I only read 48 bytes. I don't want to keep turning on an off the RTS signal, for the validity of the checkWaterMarkLevel. I do this check after I have received data do not want to drop any data.

    If you have better way of doing this let me know.


    bool CircularBuffer::checkWaterMarkLevel()
    {
    bool waterMarkLevelcheck = false;
    int waterMarkLevel;

    waterMarkLevel = bufferSize/2;

    if( writeCount - readCount >= waterMarkLevel)
    {
    waterMarkLevelcheck = false;
    }
    else
    {
    waterMarkLevelcheck = true;
    }

    return waterMarkLevelcheck;
    }

  2. #2
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: need help with circularbuffer warkmark level

    I have no idea what you are trying to do, and since I have no information on what a watermark or how you implemented you circular buffer, I can't help much either.

    I will say this though. boost has a circular_buffer container. Maybe using that could help?

    I don't see how a watermark could be part of a circular buffer. Don't mix container and containee details.
    Is your question related to IO?
    Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
    It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured