summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-03-14 16:06:28 +0100
committerMartin Sustrik <sustrik@250bpm.com>2012-03-14 16:06:28 +0100
commitfc9dc49cbf4571c8a17048d19f342408999e2164 (patch)
tree3e5107be7df5e58e33d3b574e405590be32679f8 /doc
parentc8102f6ef6394357d2d1a53c579bca574a3e3c6a (diff)
parentd5064791e2c4b5e8f9ce46c47272fd054c16e4af (diff)
Merge branch 'doc-updates' of git.lucina.net:libxsv1.0.0
Diffstat (limited to 'doc')
-rw-r--r--doc/xs.txt83
-rw-r--r--doc/xs_init.txt23
-rw-r--r--doc/xs_poll.txt2
-rw-r--r--doc/xs_recv.txt32
-rw-r--r--doc/xs_recvmsg.txt16
-rw-r--r--doc/xs_send.txt23
-rw-r--r--doc/xs_sendmsg.txt13
-rw-r--r--doc/xs_setctxopt.txt31
-rw-r--r--doc/xs_zmq.txt2
9 files changed, 146 insertions, 79 deletions
diff --git a/doc/xs.txt b/doc/xs.txt
index cf5ce14..8320dbd 100644
--- a/doc/xs.txt
+++ b/doc/xs.txt
@@ -16,12 +16,20 @@ SYNOPSIS
DESCRIPTION
-----------
-Crossroads I/O is a library which extends the standard
-socket interfaces with features traditionally provided by specialised
-_messaging middleware_ products. Crossroads sockets provide an abstraction of
-asynchronous _message queues_, multiple _messaging patterns_, message
-filtering (_subscriptions_), seamless access to multiple _transport protocols_
-and more.
+Crossroads I/O is a library for building scalable and high performance
+distributed applications. It fits between classic BSD sockets,
+JMS/AMQP-style message queues, and enterprise message-oriented middleware.
+
+Crossroads I/O extends the standard socket interfaces with features
+traditionally provided by specialised _messaging middleware_ products.
+Crossroads sockets provide an abstraction of asynchronous _message
+queues_, multiple _messaging patterns_, message filtering
+(_subscriptions_), seamless access to multiple _transport protocols_ and
+more.
+
+Crossroads I/O provides a native C API for applications. Support for many
+more languages is provided by the community through language bindings which
+can be found at the Crossroads website.
This documentation presents an overview of Crossroads concepts, describes how
Crossroads abstract standard sockets and provides a reference manual for the
@@ -40,18 +48,25 @@ Initialise Crossroads context::
Terminate Crossroads context::
linkxs:xs_term[3]
+Set Crossroads context options::
+ linkxs:xs_setctxopt[3]
+
Thread safety
^^^^^^^^^^^^^
A 'context' is thread safe and may be shared among as many application
-threads as necessary, without any additional locking required on the part of
-the caller.
-
-Individual Crossroads 'sockets' are _not_ thread safe except in the case where
-full memory barriers are issued when migrating a socket from one thread to
-another. In practice this means applications can create a socket in one thread
-with _xs_socket()_ and then pass it to a _newly created_ thread as part of
-thread initialization, for example via a structure passed as an argument to
+threads as necessary, without any additional locking required on the part
+of the caller.
+
+The individual 'sockets' within a 'context' are _not_ thread safe --
+applications may _not_ use a single 'socket' concurrently from multiple
+threads.
+
+A 'socket' _may_ be _migrated_ from one thread to another, by issuing a
+full memory barrier between individual calls on the 'socket'. For example,
+this means applications can create a socket in one thread with
+_xs_socket()_ and then pass it to a _newly created_ thread as part of
+thread initialization via a structure passed as an argument to
_pthread_create()_.
@@ -60,18 +75,28 @@ Multiple contexts
Multiple 'contexts' may coexist within a single application. Thus, an
application can use Crossroads directly and at the same time make use of any
number of additional libraries or components which themselves make use of
-Crossroads as long as the above guidelines regarding thread safety are adhered
-to.
+Crossroads.
Messages
~~~~~~~~
-A Crossroads message is a discrete unit of data passed between applications or
-components of the same application. Crossroads messages have no internal
+A Crossroads message is a discrete unit of data passed between applications
+or components of the same application. Crossroads messages have no internal
structure and from the point of view of Crossroads themselves they are
considered to be opaque binary data.
-The following functions are provided to work with messages:
+Applications using the Crossroads library send and receive messages
+directly from/to buffers provided by the application, using the Crossroads
+functions _xs_send()_ and _xs_recv()_.
+
+Alternatively, applications desiring zero-copy messaging and/or reference
+counted allocation of messages can use the message handling functions
+described in this section, and send and receive messages using
+_xs_sendmsg()_ and _xs_recvmsg()_ respectively. These two approaches are
+interchangeable.
+
+The following functions are provided to work with messages using zero-copy
+and/or reference-counted allocation of messages:
Initialise a message::
linkxs:xs_msg_init[3]
@@ -89,6 +114,9 @@ Message manipulation::
linkxs:xs_msg_copy[3]
linkxs:xs_msg_move[3]
+Retrieve message option::
+ linkxs:xs_getmsgopt[3]
+
Sockets
~~~~~~~
@@ -116,8 +144,12 @@ Sending and receiving messages::
linkxs:xs_send[3]
linkxs:xs_recv[3]
+Sending and receiving messages (zero-copy)::
+ linkxs:xs_sendmsg[3]
+ linkxs:xs_recvmsg[3]
+
.Input/output multiplexing
-Crossroads provide a mechanism for applications to multiplex input/output events
+Crossroads provides a mechanism for applications to multiplex input/output events
over a set containing both Crossroads sockets and standard sockets. This
mechanism mirrors the standard _poll()_ system call, and is described in detail
in linkxs:xs_poll[3].
@@ -143,6 +175,7 @@ Local inter-process communication transport::
Local in-process (inter-thread) communication transport::
linkxs:xs_inproc[7]
+
ERROR HANDLING
--------------
The Crossroads library functions handle errors using the standard conventions
@@ -191,6 +224,10 @@ and Martin Lucina <martin@lucina.net>.
COPYING
-------
-Free use of Crossroads library is granted under the terms of the GNU Lesser
-General Public License (LGPL). For details see the files `COPYING` and
-`COPYING.LESSER` included with the Crossroads distribution.
+Free use of the Crossroads library software is granted under the terms of
+the GNU Lesser General Public License (LGPL). For details see the files
+`COPYING` and `COPYING.LESSER` included with the libxs distribution.
+
+As a special exception, the copyright holders of libxs grant you the right
+to link the library statically with your software. Refer to the end of
+the `COPYING.LESSER` file included with the libxs distribution for details.
diff --git a/doc/xs_init.txt b/doc/xs_init.txt
index 373822a..40a64bf 100644
--- a/doc/xs_init.txt
+++ b/doc/xs_init.txt
@@ -21,6 +21,28 @@ A 'context' is thread safe and may be shared among as many application
threads as necessary, without any additional locking required on the part of
the caller.
+The individual 'sockets' within a 'context' are _not_ thread safe --
+applications may _not_ use a single 'socket' concurrently from multiple
+threads.
+
+A 'socket' _may_ be _migrated_ from one thread to another, by issuing a
+full memory barrier between individual calls on the 'socket'. For example,
+this means applications can create a socket in one thread with
+_xs_socket()_ and then pass it to a _newly created_ thread as part of
+thread initialization via a structure passed as an argument to
+_pthread_create()_.
+
+.Context options
+Context options may be set prior to creating the first socket within a
+'context', using the _xs_setctxopt()_ function. See linkxs:xs_setctxopt[3]
+for details on the available context options.
+
+.Multiple contexts
+Multiple 'contexts' may coexist within a single application. Thus, an
+application can use Crossroads directly and at the same time make use of any
+number of additional libraries or components which themselves make use of
+Crossroads.
+
RETURN VALUE
------------
@@ -38,6 +60,7 @@ SEE ALSO
--------
linkxs:xs[7]
linkxs:xs_term[3]
+linkxs:xs_setctxopt[3]
AUTHORS
diff --git a/doc/xs_poll.txt b/doc/xs_poll.txt
index 37f7dc5..c809e28 100644
--- a/doc/xs_poll.txt
+++ b/doc/xs_poll.txt
@@ -10,7 +10,7 @@ xs_poll - input/output multiplexing
SYNOPSIS
--------
-*int xs_poll (xs_pollitem_t '*items', int 'nitems', long 'timeout');*
+*int xs_poll (xs_pollitem_t '*items', int 'nitems', int 'timeout');*
DESCRIPTION
diff --git a/doc/xs_recv.txt b/doc/xs_recv.txt
index 26a6c54..5706432 100644
--- a/doc/xs_recv.txt
+++ b/doc/xs_recv.txt
@@ -29,22 +29,22 @@ function shall fail with 'errno' set to EAGAIN.
Multi-part messages
~~~~~~~~~~~~~~~~~~~
-A Crossroads message is composed of 1 or more message parts. Each message
-part is an independent 'xs_msg_t' in its own right. Crossroads ensure atomic
-delivery of messages; peers shall receive either all _message parts_ of a
-message or none at all. The total number of message parts is unlimited except
-by available memory.
+A Crossroads message is composed of 1 or more message parts. Crossroads
+ensures atomic delivery of messages; peers shall receive either all
+_message parts_ of a message or none at all. The total number of message
+parts is unlimited except by available memory.
An application that processes multipart messages must use the _XS_RCVMORE_
-linkxs:xs_getsockopt[3] option after calling _xs_recv()_ to determine if
-there are further parts to receive.
+linkxs:xs_getsockopt[3] option on the 'socket' after calling _xs_recv()_ to
+determine if there are further parts to receive.
RETURN VALUE
------------
-The _xs_recv()_ function shall return number of bytes in the message
-if successful. Note that the value can exceed the value of the 'len' parameter
-in case the message was truncated. If not successful the function shall return
-`-1` and set 'errno' to one of the values defined below.
+The _xs_recv()_ function shall return the number of bytes in the received
+message if successful. Note that the value can exceed the value of the
+'len' parameter, in this case the message was truncated. If not successful
+the function shall return `-1` and set 'errno' to one of the values defined
+below.
ERRORS
@@ -79,8 +79,9 @@ assert (nbytes != -1);
SEE ALSO
--------
-linkxs:xs_recvmsg[3]
-linkxs:xs_send[3]
+Applications that wish to use zero-copy messaging must use
+linkxs:xs_recvmsg[3] instead of _xs_recv()_.
+
linkxs:xs_sendmsg[3]
linkxs:xs_getsockopt[3]
linkxs:xs_socket[7]
@@ -89,6 +90,5 @@ linkxs:xs[7]
AUTHORS
-------
-+This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
-+Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
-
+This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
+Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
diff --git a/doc/xs_recvmsg.txt b/doc/xs_recvmsg.txt
index 735fed0..4a88177 100644
--- a/doc/xs_recvmsg.txt
+++ b/doc/xs_recvmsg.txt
@@ -4,7 +4,7 @@ xs_recvmsg(3)
NAME
----
-xs_recvmsg - receive a message part from a socket
+xs_recvmsg - receive a message part from a socket (zero-copy)
SYNOPSIS
@@ -30,7 +30,7 @@ function shall fail with 'errno' set to EAGAIN.
Multi-part messages
~~~~~~~~~~~~~~~~~~~
A Crossroads message is composed of 1 or more message parts. Each message
-part is an independent 'xs_msg_t' in its own right. Crossroads ensure atomic
+part is an independent 'xs_msg_t' in its own right. Crossroads ensures atomic
delivery of messages; peers shall receive either all _message parts_ of a
message or none at all. The total number of message parts is unlimited except
by available memory.
@@ -42,9 +42,9 @@ there are further parts to receive.
RETURN VALUE
------------
-The _xs_recvmsg()_ function shall return number of bytes in the message
-if successful. Otherwise it shall return `-1` and set 'errno' to one of the
-values defined below.
+The _xs_recvmsg()_ function shall return the number of bytes in the
+received message if successful. Otherwise it shall return `-1` and set
+'errno' to one of the values defined below.
ERRORS
@@ -106,8 +106,9 @@ do {
SEE ALSO
--------
-linkxs:xs_recv[3]
-linkxs:xs_send[3]
+Applications that do not require zero-copy messaging can use the simpler
+linkxs:xs_recv[3] instead of _xs_recvmsg()_.
+
linkxs:xs_sendmsg[3]
linkxs:xs_getsockopt[3]
linkxs:xs_socket[7]
@@ -118,4 +119,3 @@ AUTHORS
-------
This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
-
diff --git a/doc/xs_send.txt b/doc/xs_send.txt
index f2d66e4..72bbf88 100644
--- a/doc/xs_send.txt
+++ b/doc/xs_send.txt
@@ -4,7 +4,7 @@ xs_send(3)
NAME
----
-xs_send - send a message part on a socket
+xs_send - send a message part on a socket
SYNOPSIS
@@ -35,14 +35,13 @@ the 'socket' and Crossroads have assumed responsibility for the message.
Multi-part messages
~~~~~~~~~~~~~~~~~~~
-A Crossroads message is composed of 1 or more message parts. Each message
-part is an independent 'xs_msg_t' in its own right. Crossroads ensure atomic
-delivery of messages; peers shall receive either all _message parts_ of a
-message or none at all. The total number of message parts is unlimited except
-by available memory.
+A Crossroads message is composed of 1 or more message parts. Crossroads
+ensures atomic delivery of messages; peers shall receive either all
+_message parts_ of a message or none at all. The total number of message
+parts is unlimited except by available memory.
An application that sends multipart messages must use the _XS_SNDMORE_ flag
-when sending each data part except the final one.
+when sending each message part except the final one.
RETURN VALUE
@@ -88,15 +87,15 @@ assert (rc == 2);
SEE ALSO
--------
-linkxs:xs_sendmsg[3]
+Applications that wish to use zero-copy messaging must use
+linkxs:xs_sendmsg[3] instead of _xs_send()_.
+
linkxs:xs_recv[3]
-linkxs:xs_recvmsg[3]
linkxs:xs_socket[7]
linkxs:xs[7]
AUTHORS
-------
-+This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
-+Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
-
+This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
+Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
diff --git a/doc/xs_sendmsg.txt b/doc/xs_sendmsg.txt
index 9478b4a..7445f25 100644
--- a/doc/xs_sendmsg.txt
+++ b/doc/xs_sendmsg.txt
@@ -4,7 +4,7 @@ xs_sendmsg(3)
NAME
----
-xs_sendmsg - send a message part on a socket
+xs_sendmsg - send a message part on a socket (zero-copy)
SYNOPSIS
@@ -48,6 +48,7 @@ by available memory.
An application that sends multipart messages must use the _XS_SNDMORE_ flag
when sending each data part except the final one.
+
RETURN VALUE
------------
The _xs_sendmsg()_ function shall return number of bytes in the message
@@ -104,8 +105,9 @@ rc = xs_sendmsg (socket, &part3, 0);
SEE ALSO
--------
-linkxs:xs_recv[3]
-linkxs:xs_recv[3]
+Applications that do not require zero-copy messaging can use the simpler
+linkxs:xs_send[3] instead of _xs_sendmsg()_.
+
linkxs:xs_recvmsg[3]
linkxs:xs_socket[7]
linkxs:xs[7]
@@ -113,6 +115,5 @@ linkxs:xs[7]
AUTHORS
-------
-+This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
-+Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
-
+This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
+Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
diff --git a/doc/xs_setctxopt.txt b/doc/xs_setctxopt.txt
index d26d319..ccdd2db 100644
--- a/doc/xs_setctxopt.txt
+++ b/doc/xs_setctxopt.txt
@@ -12,22 +12,24 @@ SYNOPSIS
--------
*int xs_setctxopt (void '*context', int 'option_name', const void '*option_value', size_t 'option_len');*
-Caution: All options take effect only if set prior to creating the first socket.
DESCRIPTION
-----------
The _xs_setctxopt()_ function shall set the option specified by the
-'option_name' argument to the value pointed to by the 'option_value' argument
-for the Crossroads context pointed to by the 'context' argument.
+'option_name' argument to the value pointed to by the 'option_value'
+argument, for the Crossroads context pointed to by the 'context' argument.
The 'option_len' argument is the size of the option value in bytes.
+CAUTION: Context options take effect only if set with _xs_setctxopt()_
+prior to creating the first socket in a given 'context' with _xs_socket()_.
+
The following options can be set with the _xs_setctxopt()_ function:
XS_MAX_SOCKETS: Set maximum number of sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The 'XS_MAX_SOCKETS' option shall set specify the maximum nuber of sockets
-that can be open at the same time.
+The 'XS_MAX_SOCKETS' option shall set the maximum nuber of sockets that can
+be simultaneously active in the given 'context'.
[horizontal]
Option value type:: int
@@ -36,8 +38,9 @@ Default value:: 512
XS_IO_THREADS: Set number of worker threads
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The 'XS_IO_THREADS' option shall set specify the size of the thread pool to
-handle I/O operations. The value should be at least 1.
+The 'XS_IO_THREADS' option shall set the size of the thread pool created by
+the given 'context' to handle I/O operations. The minimum value for this
+option is `1`.
[horizontal]
Option value type:: int
@@ -60,21 +63,23 @@ The provided 'context' was invalid.
EXAMPLE
-------
-.Setting maximal number of sockets to three.
+.Setting the number of I/O threads for a context to four.
----
-int val = 3;
-rc = xs_setctxopt (context, XS_CTX_MAX_SOCKETS, &val, sizeof (val));
+void *context = xs_init ();
+int io_threads = 4;
+rc = xs_setctxopt (context, XS_IO_THREADS, &io_threads, sizeof (io_threads));
assert (rc == 0);
+/* The above call MUST be called before any socket is created in context */
+void *socket = xs_socket (context, XS_PUB);
----
SEE ALSO
--------
-linkxs:xs_getsockopt[3]
-linkxs:xs_setsockopt[3]
linkxs:xs_init[3]
linkxs:xs[7]
AUTHORS
-------
-This manual page was written by Martin Sustrik <sustrik@250bpm.com>.
+The Crossroads documentation was written by Martin Sustrik <sustrik@250bpm.com>
+and Martin Lucina <martin@lucina.net>.
diff --git a/doc/xs_zmq.txt b/doc/xs_zmq.txt
index 310ab64..570ef5e 100644
--- a/doc/xs_zmq.txt
+++ b/doc/xs_zmq.txt
@@ -72,6 +72,8 @@ Messages
*int zmq_msg_init (zmq_msg_t '*msg');*
*int zmq_msg_init_size (zmq_msg_t '*msg', size_t 'size');*
*int zmq_msg_init_data (zmq_msg_t '*msg', void '*data', size_t 'size', zmq_free_fn '*ffn', void '*hint');*
+*size_t zmq_msg_size (zmq_msg_t '*msg');*
+*void *zmq_msg_data (zmq_msg_t '*msg');*
*int zmq_msg_close (zmq_msg_t '*msg');*
*int zmq_msg_copy (zmq_msg_t '*dest', zmq_msg_t '*src');*
*int zmq_msg_move (zmq_msg_t '*dest', zmq_msg_t '*src');*