aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-05-18 18:29:31 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-05-18 18:29:31 +0200
commit5697f8c22d0cd9ebf8e5d3408847cfd69045df2c (patch)
tree1487e38e3ee7b080cef644a2b045b6b64fa0ba04 /README.md
parentd148bbaa271ff8ad2ad4d128c6270313ef1aa79f (diff)
downloadvarchunk-5697f8c22d0cd9ebf8e5d3408847cfd69045df2c.zip
varchunk-5697f8c22d0cd9ebf8e5d3408847cfd69045df2c.tar.gz
varchunk-5697f8c22d0cd9ebf8e5d3408847cfd69045df2c.tar.bz2
varchunk-5697f8c22d0cd9ebf8e5d3408847cfd69045df2c.tar.xz
use gitlab CI provided meson cross scripts.
Diffstat (limited to 'README.md')
-rw-r--r--README.md115
1 files changed, 61 insertions, 54 deletions
diff --git a/README.md b/README.md
index f780e68..d587a9a 100644
--- a/README.md
+++ b/README.md
@@ -13,79 +13,86 @@
### Build Status
-[![Build Status](https://travis-ci.org/OpenMusicKontrollers/varchunk.svg)](https://travis-ci.org/OpenMusicKontrollers/varchunk)
+[![build status](https://gitlab.com/OpenMusicKontrollers/varchunk/badges/master/build.svg)](https://gitlab.com/OpenMusicKontrollers/varchunk/commits/master)
-### Usage
+### Build / test
+
+ git clone https://git.open-music-kontrollers.ch/lad/varchunk
+ cd varchunk
+ meson build
+ cd build
+ ninja -j4
+ ninja test
-``` c
-#include <pthread.h>
-#include <varchunk.h>
+### Usage
-static void *
-producer_main(void *arg)
-{
- varchunk_t *varchunk = arg;
- void *ptr;
- const size_t towrite = sizeof(uint32_t);
- uint32_t counter = 0;
+ #include <pthread.h>
+ #include <varchunk.h>
- while(counter <= 1000000)
+ static void *
+ producer_main(void *arg)
{
- if( (ptr = varchunk_write_request(varchunk, towrite)) )
+ varchunk_t *varchunk = arg;
+ void *ptr;
+ const size_t towrite = sizeof(uint32_t);
+ uint32_t counter = 0;
+
+ while(counter <= 1000000)
{
- // write 'towrite' bytes to 'ptr'
- *(uint32_t *)ptr = counter++;
- varchunk_write_advance(varchunk, towrite);
+ if( (ptr = varchunk_write_request(varchunk, towrite)) )
+ {
+ // write 'towrite' bytes to 'ptr'
+ *(uint32_t *)ptr = counter++;
+ varchunk_write_advance(varchunk, towrite);
+ }
}
- }
-
- return NULL;
-}
-static void *
-consumer_main(void *arg)
-{
- varchunk_t *varchunk = arg;
- const void *ptr;
- size_t toread;
+ return NULL;
+ }
- while(1)
+ static void *
+ consumer_main(void *arg)
{
- if( (ptr = varchunk_read_request(varchunk, &toread)) )
+ varchunk_t *varchunk = arg;
+ const void *ptr;
+ size_t toread;
+
+ while(1)
{
- // read 'toread' bytes from 'ptr'
- if(*(uint32_t *)ptr >= 1000000)
- break;
- varchunk_read_advance(varchunk);
+ if( (ptr = varchunk_read_request(varchunk, &toread)) )
+ {
+ // read 'toread' bytes from 'ptr'
+ if(*(uint32_t *)ptr >= 1000000)
+ break;
+ varchunk_read_advance(varchunk);
+ }
}
- }
- return NULL;
-}
+ return NULL;
+ }
-int
-main(int argc, char **argv)
-{
- if(!varchunk_is_lock_free())
- return -1;
+ int
+ main(int argc, char **argv)
+ {
+ if(!varchunk_is_lock_free())
+ return -1;
- pthread_t producer;
- pthread_t consumer;
- varchunk_t *varchunk = varchunk_new(8192, true);
- if(!varchunk)
- return -1;
+ pthread_t producer;
+ pthread_t consumer;
+ varchunk_t *varchunk = varchunk_new(8192, true);
+ if(!varchunk)
+ return -1;
- pthread_create(&consumer, NULL, consumer_main, varchunk);
- pthread_create(&producer, NULL, producer_main, varchunk);
+ pthread_create(&consumer, NULL, consumer_main, varchunk);
+ pthread_create(&producer, NULL, producer_main, varchunk);
- pthread_join(producer, NULL);
- pthread_join(consumer, NULL);
+ pthread_join(producer, NULL);
+ pthread_join(consumer, NULL);
- varchunk_free(varchunk);
+ varchunk_free(varchunk);
- return 0;
-}
-```
+ return 0;
+ }
### License