📄 vxwringbuf.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/VXWRingBuf.html - generated by refgen from /vobs/wpwr/docs/vxworks/ref/VXWRingBuf.i --> <title> VXWRingBuf </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual : Wind Foundation Classes</i></a></p></blockquote><h1>VXWRingBuf</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>VXWRingBuf</strong> - ring buffer class</p></blockquote><h4>METHODS</h4><blockquote><p><p><b><i><a href="./VXWRingBuf.html#VXWRingBuf::VXWRingBuf">VXWRingBuf::VXWRingBuf</a></i>( )</b> - create an empty ring buffer<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::VXWRingBuf_1">VXWRingBuf::VXWRingBuf</a></i>( )</b> - build ring-buffer object from existing ID<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::~VXWRingBuf">VXWRingBuf::~VXWRingBuf</a></i>( )</b> - delete ring buffer<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::get">VXWRingBuf::get</a></i>( )</b> - get characters from ring buffer<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::put">VXWRingBuf::put</a></i>( )</b> - put bytes into ring buffer<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::flush">VXWRingBuf::flush</a></i>( )</b> - make ring buffer empty<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::freeBytes">VXWRingBuf::freeBytes</a></i>( )</b> - determine the number of free bytes in ring buffer<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::isEmpty">VXWRingBuf::isEmpty</a></i>( )</b> - test whether ring buffer is empty<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::isFull">VXWRingBuf::isFull</a></i>( )</b> - test whether ring buffer is full (no more room)<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::moveAhead">VXWRingBuf::moveAhead</a></i>( )</b> - advance ring pointer by <i>n</i> bytes<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::nBytes">VXWRingBuf::nBytes</a></i>( )</b> - determine the number of bytes in ring buffer<br><b><i><a href="./VXWRingBuf.html#VXWRingBuf::putAhead">VXWRingBuf::putAhead</a></i>( )</b> - put a byte ahead in a ring buffer without moving ring pointers<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>The <b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b> class provides routines for creating and usingring buffers, which are first-in-first-out circular buffers. Theroutines simply manipulate the ring buffer data structure; nokernel functions are invoked. In particular, ring buffers bythemselves provide no task synchronization or mutual exclusion.<p>However, the ring buffer pointers are manipulated in such a waythat a reader task (invoking <b><i><a href="./VXWRingBuf.html#VXWRingBuf::get">VXWRingBuf::get</a></i>( )</b>) and a writer task(invoking <b><i><a href="./VXWRingBuf.html#VXWRingBuf::put">VXWRingBuf::put</a></i>( )</b>) can access a ring simultaneouslywithout requiring mutual exclusion. This is because readers onlyaffect a <i>read</i> pointer and writers only affect a <i>write</i>pointer in a ring buffer data structure. However, access bymultiple readers or writers <i>must</i> be interlocked through amutual exclusion mechanism (for example, a mutual-exclusionsemaphore guarding a ring buffer).<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>vxwRngLib.h</b><p><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::VXWRingBuf"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::VXWRingBuf</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::VXWRingBuf</i>( )</strong> - create an empty ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>VXWRingBuf ( int nbytes )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This constructor creates a ring buffer of size <i>nbytes</i>, and initializesit. Memory for the buffer is allocated from the system memory partition.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::VXWRingBuf_1"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::VXWRingBuf</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::VXWRingBuf</i>( )</strong> - build ring-buffer object from existing ID</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>VXWRingBuf ( RING_ID aRingId )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>Use this constructor to build a ring-buffer object from an existingring buffer. This permits you to use the C++ ring-bufferinterfaces even if the ring buffer itself was created by a routinewritten in C.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b>, <b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="VXWRingBuf::~VXWRingBuf"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::~VXWRingBuf</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::~VXWRingBuf</i>( )</strong> - delete ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> ~VXWRingBuf ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This destructor deletes a specified ring buffer.Any data in the buffer at the time it is deleted is lost.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::get"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::get</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::get</i>( )</strong> - get characters from ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int get ( char * buffer, int maxbytes )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine copies bytes from the ring buffer into <i>buffer</i>.It copies as many bytes as are available in the ring, up to <i>maxbytes</i>.The bytes copied are then removed from the ring.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>The number of bytes actually received from the ring buffer;it may be zero if the ring buffer is empty at the time of the call.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::put"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::put</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::put</i>( )</strong> - put bytes into ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int put ( char * buffer, int nBytes )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine puts bytes from <i>buffer</i> into the ring buffer. Thespecified number of bytes is put into the ring, up to the number ofbytes available in the ring.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>The number of bytes actually put into the ring buffer;it may be less than number requested, even zero,if there is insufficient room in the ring buffer at the time of the call.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::flush"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::flush</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::flush</i>( )</strong> - make ring buffer empty</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> void flush ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes the ring buffer to be empty.Any data in the buffer is lost.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::freeBytes"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::freeBytes</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::freeBytes</i>( )</strong> - determine the number of free bytes in ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> int freeBytes ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine determines the number of bytes currently unused in thering buffer.<p></blockquote><h4>RETURNS</h4><blockquote><p>The number of unused bytes in the ring buffer.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::isEmpty"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::isEmpty</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::isEmpty</i>( )</strong> - test whether ring buffer is empty</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> BOOL isEmpty ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine reports on whether the ring buffer is empty.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>TRUE if empty, FALSE if not.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::isFull"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::isFull</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::isFull</i>( )</strong> - test whether ring buffer is full (no more room)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> BOOL isFull ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine reports on whether the ring buffer is completely full.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>TRUE if full, FALSE if not.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::moveAhead"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::moveAhead</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::moveAhead</i>( )</strong> - advance ring pointer by <i>n</i> bytes</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void moveAhead ( int n )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine advances the ring buffer input pointer by <i>n</i> bytes.This makes <i>n</i> bytes available in the ring buffer, after havingbeen written ahead in the ring buffer with <b><i><a href="./VXWRingBuf.html#VXWRingBuf::putAhead">VXWRingBuf::putAhead</a></i>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::nBytes"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::nBytes</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::nBytes</i>( )</strong> - determine the number of bytes in ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> int nBytes ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine determines the number of bytes currently in thering buffer.<p></blockquote><h4>RETURNS</h4><blockquote><p>The number of bytes filled in the ring buffer.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b><hr><a name="VXWRingBuf::putAhead"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWRingBuf::putAhead</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWRingBuf::putAhead</i>( )</strong> - put a byte ahead in a ring buffer without moving ring pointers</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void putAhead ( char byte, int offset )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine writes a byte into the ring, but does not move thering buffer pointers. Thus the byte is not yet be available to<b><i><a href="./VXWRingBuf.html#VXWRingBuf::get">VXWRingBuf::get</a></i>( )</b> calls. The byte is written <i>offset</i> bytes aheadof the next input location in the ring. Thus, an offset of 0 putsthe byte in the same position as <b><i><a href="./VXWRingBuf.html#VXWRingBuf::put">VXWRingBuf::put</a></i>( )</b> would put abyte, except that the input pointer is not updated.<p>Bytes written ahead in the ring buffer with this routine can bemade available all at once by subsequently moving the ring bufferpointers with the routine <b><i><a href="./VXWRingBuf.html#VXWRingBuf::moveAhead">VXWRingBuf::moveAhead</a></i>( )</b>.<p>Before calling <b><i><a href="./VXWRingBuf.html#VXWRingBuf::putAhead">VXWRingBuf::putAhead</a></i>( )</b>, the caller must verify that at least<i>offset</i> + 1 bytes are available in the ring buffer.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWRingBuf.html#top">VXWRingBuf</a></b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -