aboutsummaryrefslogtreecommitdiff
path: root/demo/async/README.adoc
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-03-12 18:42:57 -0700
committerGarrett D'Amore <garrett@damore.org>2018-03-12 18:43:12 -0700
commite51a97112ff7744aff81764e63e07db0c1fb68a2 (patch)
treee4b838a29a0b6d54533dd58e0ed313d185e87fe3 /demo/async/README.adoc
parent55e98ae58c5856c1808e3fccb2548a76c9b8907c (diff)
downloadnng-e51a97112ff7744aff81764e63e07db0c1fb68a2.tar.gz
nng-e51a97112ff7744aff81764e63e07db0c1fb68a2.tar.bz2
nng-e51a97112ff7744aff81764e63e07db0c1fb68a2.zip
fixes #284 want async demo
Diffstat (limited to 'demo/async/README.adoc')
-rw-r--r--demo/async/README.adoc53
1 files changed, 53 insertions, 0 deletions
diff --git a/demo/async/README.adoc b/demo/async/README.adoc
new file mode 100644
index 00000000..35290616
--- /dev/null
+++ b/demo/async/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 &
+----