diff options
Diffstat (limited to 'demo/raw')
| -rw-r--r-- | demo/raw/CMakeLists.txt | 20 | ||||
| -rw-r--r-- | demo/raw/README.adoc | 35 | ||||
| -rw-r--r-- | demo/raw/raw.c (renamed from demo/raw/async.c) | 0 |
3 files changed, 43 insertions, 12 deletions
diff --git a/demo/raw/CMakeLists.txt b/demo/raw/CMakeLists.txt new file mode 100644 index 00000000..15e481d5 --- /dev/null +++ b/demo/raw/CMakeLists.txt @@ -0,0 +1,20 @@ +# +# Copyright 2018 Capitar IT Group BV <info@capitar.com> +# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +# +# This software is supplied under the terms of the MIT License, a +# copy of which should be located in the distribution where this +# file was obtained (LICENSE.txt). A copy of the license may also be +# found online at https://opensource.org/licenses/MIT. + +cmake_minimum_required (VERSION 2.8.7) + +project(raw) + +set(PARALLEL 128 CACHE STRING "Parallelism (min 4, max 1000)") + +find_package(nng CONFIG REQUIRED) + +add_executable(raw raw.c) +target_link_libraries(raw nng::nng) +target_compile_definitions(raw PRIVATE -DPARALLEL=${PARALLEL}) diff --git a/demo/raw/README.adoc b/demo/raw/README.adoc index 35290616..2190dc49 100644 --- a/demo/raw/README.adoc +++ b/demo/raw/README.adoc @@ -1,14 +1,15 @@ -= async += raw This is a simple asynchronous demo, that demonstrates use of the RAW -option with a server, along with async message handling, to obtain a +sockets with a server, along with async message handling, to obtain a very high level of asynchronous operation, suitable for use in a highly concurrent server application. == Compiling -You can override the level of concurrency with the `PARALLEL` -define. This determines how many requests the server will accept +You can override the level of concurrency with the `PARALLEL` option. + +This determines how many requests the server will accept at a time, and keep outstanding. Note that for our toy implementation, we create this many "logical" flows of execution (these are _NOT_ threads), where a request is followed by a reply. @@ -16,14 +17,24 @@ implementation, we create this many "logical" flows of execution The value of `PARALLEL` must be at least one, and may be as large as your memory will permit. (The default value is 32.) -On UNIX-style systems: +The best way to build is using cmake and Ninja build: + +[source, bash] +---- +% mkdir build +% cd build +% cmake -G Ninja .. +% ninja +---- + +You can also build the hard way. For example, on UNIX-style systems: [source, bash] ---- % export CPPFLAGS="-D PARALLEL=32 -I /usr/local/include" % export LDFLAGS="-L /usr/local/lib -lnng" % export CC="cc" -% ${CC} ${CPPFLAGS} async.c -o async ${LDFLAGS} +% ${CC} ${CPPFLAGS} raw.c -o raw ${LDFLAGS} ---- == Running @@ -42,12 +53,12 @@ In the following example, all of the clients should complete within ---- % export URL="tcp://127.0.0.1:55995" # start the server -% ./async $URL -s & +% ./raw $URL -s & # start a bunch of clients # Note that these all run concurrently! -% ./async $URL 2 & -% ./async $URL 2 & -% ./async $URL 2 & -% ./async $URL 2 & -% ./async $URL 2 & +% ./raw $URL 2 & +% ./raw $URL 2 & +% ./raw $URL 2 & +% ./raw $URL 2 & +% ./raw $URL 2 & ---- diff --git a/demo/raw/async.c b/demo/raw/raw.c index 0285d8d2..0285d8d2 100644 --- a/demo/raw/async.c +++ b/demo/raw/raw.c |
