// // QUEUE.CPP // // Source code from: // // Serial Communications: A C++ Developer's Guide, 2nd Edition // by Mark Nelson, IDG Books, 1999 // // Please see the book for information on usage. // // Most of the queue class functions are defined in QUEUE.H as // inline for speed. This routine probably won't generate // inline code with most compilers, and it is not used in the // ISR, so speed is not as critical. Thus, it gets defined // normally. #include "queue.h" int Queue::Peek( unsigned char *buf, int count ) { unsigned int index = tail_index; int total = 0; while ( total < count && index != head_index ) { *buf++ = buffer[ index++ ]; if ( index >= QueueSize ) index = 0; total++; } return total; } // ******************** END OF QUEUE.CPP *******************