Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Buffer52.hpp
00001 #ifndef _52BUFFER 00002 #define _52BUFFER 00003 00004 #include <vector> 00005 00006 namespace ARRC{ 00007 template <class type> class Buffer{ 00008 public: 00009 Buffer(unsigned size):buf(size,0),size(size),read_ref(0),write_ref(0){} 00010 type read(){ 00011 type ret = 0; 00012 if(read_ref < write_ref){ 00013 ret = buf[read_ref % size]; 00014 read_ref++; 00015 } 00016 return ret; 00017 } 00018 void write(type elem){ 00019 buf[write_ref % size] = elem; 00020 write_ref++; 00021 } 00022 bool readable(){return (read_ref < write_ref);} 00023 int datacount(){return write_ref - read_ref;} 00024 private: 00025 std::vector<type> buf; 00026 long unsigned read_ref,write_ref; 00027 long unsigned size; 00028 }; 00029 00030 } 00031 00032 #endif
Generated on Sat Jul 23 2022 18:03:05 by
1.7.2