aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2016-03-04 15:48:17 +0100
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2016-03-04 15:48:17 +0100
commite02e284e1aa072339e5aea5a28ced44495ddc83e (patch)
tree1973f47db3417dec2c7e25f81ceeecca4a6267c8 /README.md
parentf4663c91d72b4bbc68ceaa41beb9e6f3efdcd619 (diff)
downloadvarchunk-e02e284e1aa072339e5aea5a28ced44495ddc83e.zip
varchunk-e02e284e1aa072339e5aea5a28ced44495ddc83e.tar.gz
varchunk-e02e284e1aa072339e5aea5a28ced44495ddc83e.tar.bz2
varchunk-e02e284e1aa072339e5aea5a28ced44495ddc83e.tar.xz
improve usage example in README.
Diffstat (limited to 'README.md')
-rw-r--r--README.md10
1 files changed, 7 insertions, 3 deletions
diff --git a/README.md b/README.md
index 993a1cd..f1b230f 100644
--- a/README.md
+++ b/README.md
@@ -26,13 +26,15 @@ producer_main(void *arg)
{
varchunk_t *varchunk = arg;
void *ptr;
- size_t towrite = 128;
+ const size_t towrite = sizeof(uint32_t);
+ uint32_t counter = 0;
- for(unsigned i=0; i<1000000; i++)
+ while(counter <= 1000000)
{
if( (ptr = varchunk_write_request(varchunk, towrite)) )
{
// write 'towrite' bytes to 'ptr'
+ *(uint32_t *)ptr = counter++;
varchunk_write_advance(varchunk, towrite);
}
}
@@ -47,11 +49,13 @@ consumer_main(void *arg)
const void *ptr;
size_t toread;
- for(unsigned i=0; i<1000000; i++)
+ while(1)
{
if( (ptr = varchunk_read_request(varchunk, &toread)) )
{
// read 'toread' bytes from 'ptr'
+ if(*(uint32_t *)ptr >= 1000000)
+ break;
varchunk_read_advance(varchunk);
}
}