diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-12 11:37:26 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-12 15:36:12 -0700 |
| commit | 7e4fa0fcc2135e7d19410c1e642656180de04bb0 (patch) | |
| tree | 0af320b0e781a45201d743151eb94a21f846efda /demo/raw/README.adoc | |
| parent | ac917f68ef6291c0c07f4d5bd7b29eec867434bf (diff) | |
| download | nng-7e4fa0fcc2135e7d19410c1e642656180de04bb0.tar.gz nng-7e4fa0fcc2135e7d19410c1e642656180de04bb0.tar.bz2 nng-7e4fa0fcc2135e7d19410c1e642656180de04bb0.zip | |
Use contexts for new async demo.
Diffstat (limited to 'demo/raw/README.adoc')
| -rw-r--r-- | demo/raw/README.adoc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/demo/raw/README.adoc b/demo/raw/README.adoc new file mode 100644 index 00000000..35290616 --- /dev/null +++ b/demo/raw/README.adoc @@ -0,0 +1,53 @@ += async + +This is a simple asynchronous demo, that demonstrates use of the RAW +option 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 +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. + +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: + +[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} +---- + +== Running + +To run the server, use the arguments `__url__ -s`. + +To run the client, use the arguments `__url__ __msec__`. + +The _msec_ is a "delay" time that server will wait before responding. +We have these delays so simulate long running work. + +In the following example, all of the clients should complete within +2 seconds. (Assuming `PARALLEL` is defined to be large enough.) + +[source,bash] +---- +% export URL="tcp://127.0.0.1:55995" +# start the server +% ./async $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 & +---- |
