Convert ringbuffer to a template
This commit is contained in:
parent
9fc63b3e00
commit
fdb2cbcff0
4 changed files with 209 additions and 217 deletions
30
main.cpp
30
main.cpp
|
@ -6,21 +6,19 @@ using namespace std;
|
|||
|
||||
int main()
|
||||
{
|
||||
uint8_t rb_buffer[8];
|
||||
uint8_t dst_buffer[sizeof(rb_buffer) - 1];
|
||||
uint8_t data1[4] = {0, 1, 2, 3};
|
||||
uint8_t data2[4] = {4, 5, 6, 7};
|
||||
f1ll::ringbuffer<8> rb;
|
||||
uint8_t dst_buffer[7];
|
||||
uint8_t data1[] = {0, 1, 2, 3};
|
||||
uint8_t data2[] = {4, 5, 6, 7};
|
||||
|
||||
f1ll::ringbuffer rb(rb_buffer, sizeof(rb_buffer));
|
||||
|
||||
int16_t added = rb.put(data1, sizeof(data1));
|
||||
cout << "Added " << added << " bytes to the buffer. It reports " << rb.uncommited() << " uncommited and " << rb.commited()
|
||||
<< " commited bytes." << endl;
|
||||
rb.commit();
|
||||
cout << "After commit, there are " << rb.commited() << " commited and " << rb.uncommited() << " uncommited bytes in the buffer" << endl;
|
||||
added = rb.put(data1, sizeof(data1));
|
||||
cout << "Added " << added << " bytes to the buffer. It reports " << rb.uncommited() << " uncommited and " << rb.commited()
|
||||
<< " commited bytes." << endl;
|
||||
rb.commit();
|
||||
cout << "After commit, there are " << rb.commited() << " commited and " << rb.uncommited() << " uncommited bytes in the buffer" << endl;
|
||||
int16_t added = rb.put(data1, sizeof(data1));
|
||||
cout << "Added " << added << " bytes to the buffer. It reports " << rb.uncommited() << " uncommited and " << rb.commited()
|
||||
<< " commited bytes." << endl;
|
||||
rb.commit();
|
||||
cout << "After commit, there are " << rb.commited() << " commited and " << rb.uncommited() << " uncommited bytes in the buffer" << endl;
|
||||
added = rb.put(data1, sizeof(data1));
|
||||
cout << "Added " << added << " bytes to the buffer. It reports " << rb.uncommited() << " uncommited and " << rb.commited()
|
||||
<< " commited bytes." << endl;
|
||||
rb.commit();
|
||||
cout << "After commit, there are " << rb.commited() << " commited and " << rb.uncommited() << " uncommited bytes in the buffer" << endl;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue