From 4a7aad06d95701cf232198093ce396dcdbb53e5b Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:01:47 +0900 Subject: ZeroMQ renamed to Crossroads Signed-off-by: Martin Sustrik --- src/Makefile.am | 22 +- src/array.hpp | 14 +- src/atomic_counter.hpp | 70 ++--- src/atomic_ptr.hpp | 70 ++--- src/blob.hpp | 14 +- src/clock.cpp | 22 +- src/clock.hpp | 14 +- src/command.hpp | 24 +- src/config.hpp | 14 +- src/ctx.cpp | 76 +++--- src/ctx.hpp | 38 +-- src/decoder.cpp | 26 +- src/decoder.hpp | 23 +- src/devpoll.cpp | 40 +-- src/devpoll.hpp | 20 +- src/dist.cpp | 36 +-- src/dist.hpp | 32 +-- src/encoder.cpp | 18 +- src/encoder.hpp | 21 +- src/epoll.cpp | 34 +-- src/epoll.hpp | 20 +- src/err.cpp | 28 +- src/err.hpp | 50 ++-- src/fd.hpp | 17 +- src/fq.cpp | 28 +- src/fq.hpp | 14 +- src/i_engine.hpp | 16 +- src/i_poll_events.hpp | 18 +- src/io_object.cpp | 50 ++-- src/io_object.hpp | 18 +- src/io_thread.cpp | 36 +-- src/io_thread.hpp | 16 +- src/ip.cpp | 42 +-- src/ip.hpp | 14 +- src/ipc_address.cpp | 20 +- src/ipc_address.hpp | 16 +- src/ipc_connecter.cpp | 48 ++-- src/ipc_connecter.hpp | 18 +- src/ipc_listener.cpp | 32 +-- src/ipc_listener.hpp | 22 +- src/kqueue.cpp | 40 +-- src/kqueue.hpp | 20 +- src/lb.cpp | 28 +- src/lb.hpp | 14 +- src/libxs.pc.in | 10 + src/libzmq.pc.in | 10 - src/likely.hpp | 12 +- src/mailbox.cpp | 22 +- src/mailbox.hpp | 14 +- src/monitor.cpp | 24 +- src/monitor.hpp | 14 +- src/msg.cpp | 68 ++--- src/msg.hpp | 18 +- src/mtrie.cpp | 40 +-- src/mtrie.hpp | 30 +- src/mutex.hpp | 18 +- src/object.cpp | 166 +++++------ src/object.hpp | 72 ++--- src/options.cpp | 82 +++--- src/options.hpp | 12 +- src/own.cpp | 52 ++-- src/own.hpp | 20 +- src/pair.cpp | 40 +-- src/pair.hpp | 30 +- src/pgm_receiver.cpp | 50 ++-- src/pgm_receiver.hpp | 26 +- src/pgm_sender.cpp | 44 +-- src/pgm_sender.hpp | 24 +- src/pgm_socket.cpp | 146 +++++----- src/pgm_socket.hpp | 16 +- src/pipe.cpp | 76 +++--- src/pipe.hpp | 28 +- src/poll.cpp | 36 +-- src/poll.hpp | 20 +- src/poller.hpp | 80 +++--- src/poller_base.cpp | 26 +- src/poller_base.hpp | 20 +- src/precompiled.cpp | 8 +- src/precompiled.hpp | 16 +- src/pub.cpp | 20 +- src/pub.hpp | 20 +- src/pull.cpp | 28 +- src/pull.hpp | 24 +- src/push.cpp | 28 +- src/push.hpp | 24 +- src/random.cpp | 16 +- src/random.hpp | 14 +- src/reaper.cpp | 34 +-- src/reaper.hpp | 18 +- src/rep.cpp | 26 +- src/rep.hpp | 22 +- src/req.cpp | 26 +- src/req.hpp | 22 +- src/select.cpp | 50 ++-- src/select.hpp | 22 +- src/session_base.cpp | 124 ++++----- src/session_base.hpp | 40 +-- src/signaler.cpp | 120 ++++---- src/signaler.hpp | 14 +- src/socket_base.cpp | 174 ++++++------ src/socket_base.hpp | 30 +- src/stdint.hpp | 12 +- src/stream_engine.cpp | 62 ++--- src/stream_engine.hpp | 22 +- src/sub.cpp | 28 +- src/sub.hpp | 20 +- src/tcp_address.cpp | 82 +++--- src/tcp_address.hpp | 18 +- src/tcp_connecter.cpp | 58 ++-- src/tcp_connecter.hpp | 16 +- src/tcp_listener.cpp | 48 ++-- src/tcp_listener.hpp | 20 +- src/thread.cpp | 24 +- src/thread.hpp | 18 +- src/trie.cpp | 36 +-- src/trie.hpp | 14 +- src/windows.hpp | 12 +- src/wire.hpp | 12 +- src/xpub.cpp | 44 +-- src/xpub.hpp | 30 +- src/xrep.cpp | 56 ++-- src/xrep.hpp | 28 +- src/xreq.cpp | 38 +-- src/xreq.hpp | 30 +- src/xs.cpp | 727 +++++++++++++++++++++++++++++++++++++++++++++++++ src/xs_utils.cpp | 61 +++++ src/xsub.cpp | 62 ++--- src/xsub.hpp | 28 +- src/ypipe.hpp | 22 +- src/yqueue.hpp | 14 +- src/zmq.cpp | 726 ------------------------------------------------ src/zmq_utils.cpp | 61 ----- 132 files changed, 2976 insertions(+), 2972 deletions(-) create mode 100644 src/libxs.pc.in delete mode 100644 src/libzmq.pc.in create mode 100644 src/xs.cpp create mode 100644 src/xs_utils.cpp delete mode 100644 src/zmq.cpp delete mode 100644 src/zmq_utils.cpp (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index f38dd0a..0db7957 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,11 +1,11 @@ -lib_LTLIBRARIES = libzmq.la +lib_LTLIBRARIES = libxs.la pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libzmq.pc +pkgconfig_DATA = libxs.pc -include_HEADERS = ../include/zmq.h ../include/zmq_utils.h +include_HEADERS = ../include/xs.h ../include/xs_utils.h -libzmq_la_SOURCES = \ +libxs_la_SOURCES = \ array.hpp \ atomic_counter.hpp \ atomic_ptr.hpp \ @@ -130,20 +130,20 @@ libzmq_la_SOURCES = \ xrep.cpp \ xreq.cpp \ xsub.cpp \ - zmq.cpp \ - zmq_utils.cpp + xs.cpp \ + xs_utils.cpp if ON_MINGW -libzmq_la_LDFLAGS = -no-undefined -avoid-version -version-info @LTVER@ @LIBZMQ_EXTRA_LDFLAGS@ +libxs_la_LDFLAGS = -no-undefined -avoid-version -version-info @LTVER@ @LIBXS_EXTRA_LDFLAGS@ else -libzmq_la_LDFLAGS = -version-info @LTVER@ @LIBZMQ_EXTRA_LDFLAGS@ +libxs_la_LDFLAGS = -version-info @LTVER@ @LIBXS_EXTRA_LDFLAGS@ endif -libzmq_la_CXXFLAGS = @LIBZMQ_EXTRA_CXXFLAGS@ +libxs_la_CXXFLAGS = @LIBXS_EXTRA_CXXFLAGS@ if BUILD_PGM -libzmq_la_CPPFLAGS = -I$(top_srcdir)/@pgm_srcdir@/include/ -libzmq_la_LIBADD = $(top_srcdir)/@pgm_srcdir@/libpgm_noinst.la +libxs_la_CPPFLAGS = -I$(top_srcdir)/@pgm_srcdir@/include/ +libxs_la_LIBADD = $(top_srcdir)/@pgm_srcdir@/libpgm_noinst.la endif dist-hook: diff --git a/src/array.hpp b/src/array.hpp index 7e4ddd4..260558d 100644 --- a/src/array.hpp +++ b/src/array.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,13 +19,13 @@ along with this program. If not, see . */ -#ifndef __ZMQ_ARRAY_INCLUDED__ -#define __ZMQ_ARRAY_INCLUDED__ +#ifndef __XS_ARRAY_INCLUDED__ +#define __XS_ARRAY_INCLUDED__ #include #include -namespace zmq +namespace xs { // Base class for objects stored in the array. If you want to store diff --git a/src/atomic_counter.hpp b/src/atomic_counter.hpp index a0a67bf..81779a5 100644 --- a/src/atomic_counter.hpp +++ b/src/atomic_counter.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,33 +19,33 @@ along with this program. If not, see . */ -#ifndef __ZMQ_ATOMIC_COUNTER_HPP_INCLUDED__ -#define __ZMQ_ATOMIC_COUNTER_HPP_INCLUDED__ +#ifndef __XS_ATOMIC_COUNTER_HPP_INCLUDED__ +#define __XS_ATOMIC_COUNTER_HPP_INCLUDED__ #include "stdint.hpp" #include "platform.hpp" -#if defined ZMQ_FORCE_MUTEXES -#define ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_FORCE_MUTEXES +#define XS_ATOMIC_COUNTER_MUTEX #elif (defined __i386__ || defined __x86_64__) && defined __GNUC__ -#define ZMQ_ATOMIC_COUNTER_X86 -#elif defined ZMQ_HAVE_WINDOWS -#define ZMQ_ATOMIC_COUNTER_WINDOWS -#elif (defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_NETBSD) -#define ZMQ_ATOMIC_COUNTER_ATOMIC_H +#define XS_ATOMIC_COUNTER_X86 +#elif defined XS_HAVE_WINDOWS +#define XS_ATOMIC_COUNTER_WINDOWS +#elif (defined XS_HAVE_SOLARIS || defined XS_HAVE_NETBSD) +#define XS_ATOMIC_COUNTER_ATOMIC_H #else -#define ZMQ_ATOMIC_COUNTER_MUTEX +#define XS_ATOMIC_COUNTER_MUTEX #endif -#if defined ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_ATOMIC_COUNTER_MUTEX #include "mutex.hpp" -#elif defined ZMQ_ATOMIC_COUNTER_WINDOWS +#elif defined XS_ATOMIC_COUNTER_WINDOWS #include "windows.hpp" -#elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H +#elif defined XS_ATOMIC_COUNTER_ATOMIC_H #include #endif -namespace zmq +namespace xs { // This class represents an integer that can be incremented/decremented @@ -77,18 +77,18 @@ namespace zmq { integer_t old_value; -#if defined ZMQ_ATOMIC_COUNTER_WINDOWS +#if defined XS_ATOMIC_COUNTER_WINDOWS old_value = InterlockedExchangeAdd ((LONG*) &value, increment_); -#elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H +#elif defined XS_ATOMIC_COUNTER_ATOMIC_H integer_t new_value = atomic_add_32_nv (&value, increment_); old_value = new_value - increment_; -#elif defined ZMQ_ATOMIC_COUNTER_X86 +#elif defined XS_ATOMIC_COUNTER_X86 __asm__ volatile ( "lock; xadd %0, %1 \n\t" : "=r" (old_value), "=m" (value) : "0" (increment_), "m" (value) : "cc", "memory"); -#elif defined ZMQ_ATOMIC_COUNTER_MUTEX +#elif defined XS_ATOMIC_COUNTER_MUTEX sync.lock (); old_value = value; value += increment_; @@ -102,15 +102,15 @@ namespace zmq // Atomic subtraction. Returns false if the counter drops to zero. inline bool sub (integer_t decrement) { -#if defined ZMQ_ATOMIC_COUNTER_WINDOWS +#if defined XS_ATOMIC_COUNTER_WINDOWS LONG delta = - ((LONG) decrement); integer_t old = InterlockedExchangeAdd ((LONG*) &value, delta); return old - decrement != 0; -#elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H +#elif defined XS_ATOMIC_COUNTER_ATOMIC_H int32_t delta = - ((int32_t) decrement); integer_t nv = atomic_add_32_nv (&value, delta); return nv != 0; -#elif defined ZMQ_ATOMIC_COUNTER_X86 +#elif defined XS_ATOMIC_COUNTER_X86 integer_t oldval = -decrement; volatile integer_t *val = &value; __asm__ volatile ("lock; xaddl %0,%1" @@ -118,7 +118,7 @@ namespace zmq : "0" (oldval), "m" (*val) : "cc", "memory"); return oldval != decrement; -#elif defined ZMQ_ATOMIC_COUNTER_MUTEX +#elif defined XS_ATOMIC_COUNTER_MUTEX sync.lock (); value -= decrement; bool result = value ? true : false; @@ -137,7 +137,7 @@ namespace zmq private: volatile integer_t value; -#if defined ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_ATOMIC_COUNTER_MUTEX mutex_t sync; #endif @@ -148,17 +148,17 @@ namespace zmq } // Remove macros local to this file. -#if defined ZMQ_ATOMIC_COUNTER_WINDOWS -#undef ZMQ_ATOMIC_COUNTER_WINDOWS +#if defined XS_ATOMIC_COUNTER_WINDOWS +#undef XS_ATOMIC_COUNTER_WINDOWS #endif -#if defined ZMQ_ATOMIC_COUNTER_ATOMIC_H -#undef ZMQ_ATOMIC_COUNTER_ATOMIC_H +#if defined XS_ATOMIC_COUNTER_ATOMIC_H +#undef XS_ATOMIC_COUNTER_ATOMIC_H #endif -#if defined ZMQ_ATOMIC_COUNTER_X86 -#undef ZMQ_ATOMIC_COUNTER_X86 +#if defined XS_ATOMIC_COUNTER_X86 +#undef XS_ATOMIC_COUNTER_X86 #endif -#if defined ZMQ_ATOMIC_COUNTER_MUTEX -#undef ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_ATOMIC_COUNTER_MUTEX +#undef XS_ATOMIC_COUNTER_MUTEX #endif #endif diff --git a/src/atomic_ptr.hpp b/src/atomic_ptr.hpp index c59ab81..c7062ac 100644 --- a/src/atomic_ptr.hpp +++ b/src/atomic_ptr.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,32 +19,32 @@ along with this program. If not, see . */ -#ifndef __ZMQ_ATOMIC_PTR_HPP_INCLUDED__ -#define __ZMQ_ATOMIC_PTR_HPP_INCLUDED__ +#ifndef __XS_ATOMIC_PTR_HPP_INCLUDED__ +#define __XS_ATOMIC_PTR_HPP_INCLUDED__ #include "platform.hpp" -#if defined ZMQ_FORCE_MUTEXES -#define ZMQ_ATOMIC_PTR_MUTEX +#if defined XS_FORCE_MUTEXES +#define XS_ATOMIC_PTR_MUTEX #elif (defined __i386__ || defined __x86_64__) && defined __GNUC__ -#define ZMQ_ATOMIC_PTR_X86 -#elif defined ZMQ_HAVE_WINDOWS -#define ZMQ_ATOMIC_PTR_WINDOWS -#elif (defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_NETBSD) -#define ZMQ_ATOMIC_PTR_ATOMIC_H +#define XS_ATOMIC_PTR_X86 +#elif defined XS_HAVE_WINDOWS +#define XS_ATOMIC_PTR_WINDOWS +#elif (defined XS_HAVE_SOLARIS || defined XS_HAVE_NETBSD) +#define XS_ATOMIC_PTR_ATOMIC_H #else -#define ZMQ_ATOMIC_PTR_MUTEX +#define XS_ATOMIC_PTR_MUTEX #endif -#if defined ZMQ_ATOMIC_PTR_MUTEX +#if defined XS_ATOMIC_PTR_MUTEX #include "mutex.hpp" -#elif defined ZMQ_ATOMIC_PTR_WINDOWS +#elif defined XS_ATOMIC_PTR_WINDOWS #include "windows.hpp" -#elif defined ZMQ_ATOMIC_PTR_ATOMIC_H +#elif defined XS_ATOMIC_PTR_ATOMIC_H #include #endif -namespace zmq +namespace xs { // This class encapsulates several atomic operations on pointers. @@ -76,18 +76,18 @@ namespace zmq // to the 'val' value. Old value is returned. inline T *xchg (T *val_) { -#if defined ZMQ_ATOMIC_PTR_WINDOWS +#if defined XS_ATOMIC_PTR_WINDOWS return (T*) InterlockedExchangePointer ((PVOID*) &ptr, val_); -#elif defined ZMQ_ATOMIC_PTR_ATOMIC_H +#elif defined XS_ATOMIC_PTR_ATOMIC_H return (T*) atomic_swap_ptr (&ptr, val_); -#elif defined ZMQ_ATOMIC_PTR_X86 +#elif defined XS_ATOMIC_PTR_X86 T *old; __asm__ volatile ( "lock; xchg %0, %2" : "=r" (old), "=m" (ptr) : "m" (ptr), "0" (val_)); return old; -#elif defined ZMQ_ATOMIC_PTR_MUTEX +#elif defined XS_ATOMIC_PTR_MUTEX sync.lock (); T *old = (T*) ptr; ptr = val_; @@ -104,12 +104,12 @@ namespace zmq // is returned. inline T *cas (T *cmp_, T *val_) { -#if defined ZMQ_ATOMIC_PTR_WINDOWS +#if defined XS_ATOMIC_PTR_WINDOWS return (T*) InterlockedCompareExchangePointer ( (volatile PVOID*) &ptr, val_, cmp_); -#elif defined ZMQ_ATOMIC_PTR_ATOMIC_H +#elif defined XS_ATOMIC_PTR_ATOMIC_H return (T*) atomic_cas_ptr (&ptr, cmp_, val_); -#elif defined ZMQ_ATOMIC_PTR_X86 +#elif defined XS_ATOMIC_PTR_X86 T *old; __asm__ volatile ( "lock; cmpxchg %2, %3" @@ -117,7 +117,7 @@ namespace zmq : "r" (val_), "m" (ptr), "0" (cmp_) : "cc"); return old; -#elif defined ZMQ_ATOMIC_PTR_MUTEX +#elif defined XS_ATOMIC_PTR_MUTEX sync.lock (); T *old = (T*) ptr; if (ptr == cmp_) @@ -132,7 +132,7 @@ namespace zmq private: volatile T *ptr; -#if defined ZMQ_ATOMIC_PTR_MUTEX +#if defined XS_ATOMIC_PTR_MUTEX mutex_t sync; #endif @@ -143,17 +143,17 @@ namespace zmq } // Remove macros local to this file. -#if defined ZMQ_ATOMIC_PTR_WINDOWS -#undef ZMQ_ATOMIC_PTR_WINDOWS +#if defined XS_ATOMIC_PTR_WINDOWS +#undef XS_ATOMIC_PTR_WINDOWS #endif -#if defined ZMQ_ATOMIC_PTR_ATOMIC_H -#undef ZMQ_ATOMIC_PTR_ATOMIC_H +#if defined XS_ATOMIC_PTR_ATOMIC_H +#undef XS_ATOMIC_PTR_ATOMIC_H #endif -#if defined ZMQ_ATOMIC_PTR_X86 -#undef ZMQ_ATOMIC_PTR_X86 +#if defined XS_ATOMIC_PTR_X86 +#undef XS_ATOMIC_PTR_X86 #endif -#if defined ZMQ_ATOMIC_PTR_MUTEX -#undef ZMQ_ATOMIC_PTR_MUTEX +#if defined XS_ATOMIC_PTR_MUTEX +#undef XS_ATOMIC_PTR_MUTEX #endif #endif diff --git a/src/blob.hpp b/src/blob.hpp index b8039c4..aabcf1d 100644 --- a/src/blob.hpp +++ b/src/blob.hpp @@ -1,15 +1,15 @@ /* - Copyright (c) 2010 250bpm s.r.o. + Copyright (c) 2010-2012 250bpm s.r.o. Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -18,12 +18,12 @@ along with this program. If not, see . */ -#ifndef __ZMQ_BLOB_HPP_INCLUDED__ -#define __ZMQ_BLOB_HPP_INCLUDED__ +#ifndef __XS_BLOB_HPP_INCLUDED__ +#define __XS_BLOB_HPP_INCLUDED__ #include -namespace zmq +namespace xs { // Object to hold dynamically allocated opaque binary data. diff --git a/src/clock.cpp b/src/clock.cpp index 4868a5f..0406c0a 100644 --- a/src/clock.cpp +++ b/src/clock.cpp @@ -1,15 +1,15 @@ /* - Copyright (c) 2010-2011 250bpm s.r.o. + Copyright (c) 2010-2012 250bpm s.r.o. Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -30,7 +30,7 @@ #include #endif -#if !defined ZMQ_HAVE_WINDOWS +#if !defined XS_HAVE_WINDOWS #include #endif @@ -38,19 +38,19 @@ #include #endif -zmq::clock_t::clock_t () : +xs::clock_t::clock_t () : last_tsc (rdtsc ()), last_time (now_us () / 1000) { } -zmq::clock_t::~clock_t () +xs::clock_t::~clock_t () { } -uint64_t zmq::clock_t::now_us () +uint64_t xs::clock_t::now_us () { -#if defined ZMQ_HAVE_WINDOWS +#if defined XS_HAVE_WINDOWS // Get the high resolution counter's accuracy. LARGE_INTEGER ticksPerSecond; @@ -84,7 +84,7 @@ uint64_t zmq::clock_t::now_us () #endif } -uint64_t zmq::clock_t::now_ms () +uint64_t xs::clock_t::now_ms () { uint64_t tsc = rdtsc (); @@ -103,7 +103,7 @@ uint64_t zmq::clock_t::now_ms () return last_time; } -uint64_t zmq::clock_t::rdtsc () +uint64_t xs::clock_t::rdtsc () { #if (defined _MSC_VER && (defined _M_IX86 || defined _M_X64)) return __rdtsc (); diff --git a/src/clock.hpp b/src/clock.hpp index b3b19b2..d19b00f 100644 --- a/src/clock.hpp +++ b/src/clock.hpp @@ -1,15 +1,15 @@ /* - Copyright (c) 2010-2011 250bpm s.r.o. + Copyright (c) 2010-2012 250bpm s.r.o. Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -18,12 +18,12 @@ along with this program. If not, see . */ -#ifndef __ZMQ_CLOCK_HPP_INCLUDED__ -#define __ZMQ_CLOCK_HPP_INCLUDED__ +#ifndef __XS_CLOCK_HPP_INCLUDED__ +#define __XS_CLOCK_HPP_INCLUDED__ #include "stdint.hpp" -namespace zmq +namespace xs { class clock_t diff --git a/src/command.hpp b/src/command.hpp index 8378369..5d0221e 100644 --- a/src/command.hpp +++ b/src/command.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,12 +19,12 @@ along with this program. If not, see . */ -#ifndef __ZMQ_COMMAND_HPP_INCLUDED__ -#define __ZMQ_COMMAND_HPP_INCLUDED__ +#ifndef __XS_COMMAND_HPP_INCLUDED__ +#define __XS_COMMAND_HPP_INCLUDED__ #include "stdint.hpp" -namespace zmq +namespace xs { class object_t; @@ -38,7 +38,7 @@ namespace zmq struct command_t { // Object to process the command. - zmq::object_t *destination; + xs::object_t *destination; enum type_t { @@ -73,7 +73,7 @@ namespace zmq // Sent to socket to let it know about the newly created object. struct { - zmq::own_t *object; + xs::own_t *object; } own; // Attach the engine to the session. If engine is NULL, it informs @@ -85,7 +85,7 @@ namespace zmq // Sent from session to socket to establish pipe(s) between them. // Caller have used inc_seqnum beforehand sending the command. struct { - zmq::pipe_t *pipe; + xs::pipe_t *pipe; } bind; // Sent by pipe writer to inform dormant pipe reader that there @@ -118,7 +118,7 @@ namespace zmq // Sent by I/O object ot the socket to request the shutdown of // the I/O object. struct { - zmq::own_t *object; + xs::own_t *object; } term_req; // Sent by socket to I/O object to start its shutdown. @@ -134,7 +134,7 @@ namespace zmq // Transfers the ownership of the closed socket // to the reaper thread. struct { - zmq::socket_base_t *socket; + xs::socket_base_t *socket; } reap; // Closed socket notifies the reaper that it's already deallocated. diff --git a/src/config.hpp b/src/config.hpp index f7b4c50..e4d948e 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,10 +19,10 @@ along with this program. If not, see . */ -#ifndef __ZMQ_CONFIG_HPP_INCLUDED__ -#define __ZMQ_CONFIG_HPP_INCLUDED__ +#ifndef __XS_CONFIG_HPP_INCLUDED__ +#define __XS_CONFIG_HPP_INCLUDED__ -namespace zmq +namespace xs { // Compile-time settings. diff --git a/src/ctx.cpp b/src/ctx.cpp index d771f6f..2beda82 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -3,14 +3,14 @@ Copyright (c) 2007-2011 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -20,7 +20,7 @@ */ #include "platform.hpp" -#if defined ZMQ_HAVE_WINDOWS +#if defined XS_HAVE_WINDOWS #include "windows.hpp" #else #include @@ -38,17 +38,17 @@ #include "err.hpp" #include "msg.hpp" -zmq::ctx_t::ctx_t (uint32_t io_threads_) : +xs::ctx_t::ctx_t (uint32_t io_threads_) : tag (0xbadcafe0), terminating (false) { // Initialise the array of mailboxes. Additional three slots are for - // zmq_term thread and reaper thread. + // xs_term thread and reaper thread. slot_count = max_sockets + io_threads_ + 3; slots = (mailbox_t**) malloc (sizeof (mailbox_t*) * slot_count); alloc_assert (slots); - // Initialise the infrastructure for zmq_term thread. + // Initialise the infrastructure for xs_term thread. slots [term_tid] = &term_mailbox; // Create the reaper thread. @@ -74,34 +74,34 @@ zmq::ctx_t::ctx_t (uint32_t io_threads_) : } // Create the socket to send logs to. - log_socket = create_socket (ZMQ_PUB); - zmq_assert (log_socket); + log_socket = create_socket (XS_PUB); + xs_assert (log_socket); int linger = 0; - int rc = log_socket->setsockopt (ZMQ_LINGER, &linger, sizeof (linger)); + int rc = log_socket->setsockopt (XS_LINGER, &linger, sizeof (linger)); errno_assert (rc == 0); int hwm = 1; - rc = log_socket->setsockopt (ZMQ_SNDHWM, &hwm, sizeof (hwm)); + rc = log_socket->setsockopt (XS_SNDHWM, &hwm, sizeof (hwm)); errno_assert (rc == 0); - rc = log_socket->connect ("ipc:///tmp/zmqlogs.ipc"); + rc = log_socket->connect ("ipc:///tmp/xslogs.ipc"); errno_assert (rc == 0); // Create the monitor object. io_thread_t *io_thread = choose_io_thread (0); - zmq_assert (io_thread); + xs_assert (io_thread); monitor = new (std::nothrow) monitor_t (io_thread); alloc_assert (monitor); monitor->start (); } -bool zmq::ctx_t::check_tag () +bool xs::ctx_t::check_tag () { return tag == 0xbadcafe0; } -zmq::ctx_t::~ctx_t () +xs::ctx_t::~ctx_t () { // Check that there are no remaining sockets. - zmq_assert (sockets.empty ()); + xs_assert (sockets.empty ()); // Ask I/O threads to terminate. If stop signal wasn't sent to I/O // thread subsequent invocation of destructor would hang-up. @@ -124,7 +124,7 @@ zmq::ctx_t::~ctx_t () tag = 0xdeadbeef; } -int zmq::ctx_t::terminate () +int xs::ctx_t::terminate () { // Check whether termination was already underway, but interrupted and now // restarted. @@ -139,13 +139,13 @@ int zmq::ctx_t::terminate () monitor->stop (); command_t cmd; int rc = term_mailbox.recv (&cmd, -1); - zmq_assert (rc == 0); - zmq_assert (cmd.type == command_t::done); + xs_assert (rc == 0); + xs_assert (cmd.type == command_t::done); // Close the logging socket. log_sync.lock (); rc = log_socket->close (); - zmq_assert (rc == 0); + xs_assert (rc == 0); log_socket = NULL; log_sync.unlock (); @@ -166,10 +166,10 @@ int zmq::ctx_t::terminate () int rc = term_mailbox.recv (&cmd, -1); if (rc == -1 && errno == EINTR) return -1; - zmq_assert (rc == 0); - zmq_assert (cmd.type == command_t::done); + xs_assert (rc == 0); + xs_assert (cmd.type == command_t::done); slot_sync.lock (); - zmq_assert (sockets.empty ()); + xs_assert (sockets.empty ()); slot_sync.unlock (); // Deallocate the resources. @@ -178,11 +178,11 @@ int zmq::ctx_t::terminate () return 0; } -zmq::socket_base_t *zmq::ctx_t::create_socket (int type_) +xs::socket_base_t *xs::ctx_t::create_socket (int type_) { slot_sync.lock (); - // Once zmq_term() was called, we can't create new sockets. + // Once xs_term() was called, we can't create new sockets. if (terminating) { slot_sync.unlock (); errno = ETERM; @@ -218,7 +218,7 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_) return s; } -void zmq::ctx_t::destroy_socket (class socket_base_t *socket_) +void xs::ctx_t::destroy_socket (class socket_base_t *socket_) { slot_sync.lock (); @@ -230,7 +230,7 @@ void zmq::ctx_t::destroy_socket (class socket_base_t *socket_) // Remove the socket from the list of sockets. sockets.erase (socket_); - // If zmq_term() was already called and there are no more socket + // If xs_term() was already called and there are no more socket // we can ask reaper thread to terminate. if (terminating && sockets.empty ()) reaper->stop (); @@ -238,17 +238,17 @@ void zmq::ctx_t::destroy_socket (class socket_base_t *socket_) slot_sync.unlock (); } -zmq::object_t *zmq::ctx_t::get_reaper () +xs::object_t *xs::ctx_t::get_reaper () { return reaper; } -void zmq::ctx_t::send_command (uint32_t tid_, const command_t &command_) +void xs::ctx_t::send_command (uint32_t tid_, const command_t &command_) { slots [tid_]->send (command_); } -zmq::io_thread_t *zmq::ctx_t::choose_io_thread (uint64_t affinity_) +xs::io_thread_t *xs::ctx_t::choose_io_thread (uint64_t affinity_) { if (io_threads.empty ()) return NULL; @@ -265,11 +265,11 @@ zmq::io_thread_t *zmq::ctx_t::choose_io_thread (uint64_t affinity_) } } } - zmq_assert (min_load != -1); + xs_assert (min_load != -1); return io_threads [result]; } -int zmq::ctx_t::register_endpoint (const char *addr_, endpoint_t &endpoint_) +int xs::ctx_t::register_endpoint (const char *addr_, endpoint_t &endpoint_) { endpoints_sync.lock (); @@ -285,7 +285,7 @@ int zmq::ctx_t::register_endpoint (const char *addr_, endpoint_t &endpoint_) return 0; } -void zmq::ctx_t::unregister_endpoints (socket_base_t *socket_) +void xs::ctx_t::unregister_endpoints (socket_base_t *socket_) { endpoints_sync.lock (); @@ -303,7 +303,7 @@ void zmq::ctx_t::unregister_endpoints (socket_base_t *socket_) endpoints_sync.unlock (); } -zmq::endpoint_t zmq::ctx_t::find_endpoint (const char *addr_) +xs::endpoint_t xs::ctx_t::find_endpoint (const char *addr_) { endpoints_sync.lock (); @@ -326,18 +326,18 @@ zmq::endpoint_t zmq::ctx_t::find_endpoint (const char *addr_) return *endpoint; } -void zmq::ctx_t::log (int sid_, const char *text_) +void xs::ctx_t::log (int sid_, const char *text_) { monitor->log (sid_, text_); } -void zmq::ctx_t::publish_logs (const char *text_) +void xs::ctx_t::publish_logs (const char *text_) { log_sync.lock (); msg_t msg; msg.init_size (strlen (text_) + 1); memcpy (msg.data (), text_, strlen (text_) + 1); - int rc = log_socket->send (&msg, ZMQ_DONTWAIT); + int rc = log_socket->send (&msg, XS_DONTWAIT); errno_assert (rc == 0); msg.close (); log_sync.unlock (); @@ -346,5 +346,5 @@ void zmq::ctx_t::publish_logs (const char *text_) // The last used socket ID, or 0 if no socket was used so far. Note that this // is a global variable. Thus, even sockets created in different contexts have // unique IDs. -zmq::atomic_counter_t zmq::ctx_t::max_socket_id; +xs::atomic_counter_t xs::ctx_t::max_socket_id; diff --git a/src/ctx.hpp b/src/ctx.hpp index 2859282..a813e60 100644 --- a/src/ctx.hpp +++ b/src/ctx.hpp @@ -3,14 +3,14 @@ Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,8 +19,8 @@ along with this program. If not, see . */ -#ifndef __ZMQ_CTX_HPP_INCLUDED__ -#define __ZMQ_CTX_HPP_INCLUDED__ +#ifndef __XS_CTX_HPP_INCLUDED__ +#define __XS_CTX_HPP_INCLUDED__ #include #include @@ -35,7 +35,7 @@ #include "options.hpp" #include "atomic_counter.hpp" -namespace zmq +namespace xs { class object_t; @@ -67,15 +67,15 @@ namespace zmq // Returns false if object is not a context. bool check_tag (); - // This function is called when user invokes zmq_term. If there are + // This function is called when user invokes xs_term. If there are // no more sockets open it'll cause all the infrastructure to be shut // down. If there are open sockets still, the deallocation happens // after the last one is closed. int terminate (); // Create and destroy a socket. - zmq::socket_base_t *create_socket (int type_); - void destroy_socket (zmq::socket_base_t *socket_); + xs::socket_base_t *create_socket (int type_); + void destroy_socket (xs::socket_base_t *socket_); // Send command to the destination thread. void send_command (uint32_t tid_, const command_t &command_); @@ -83,14 +83,14 @@ namespace zmq // Returns the I/O thread that is the least busy at the moment. // Affinity specifies which I/O threads are eligible (0 = all). // Returns NULL is no I/O thread is available. - zmq::io_thread_t *choose_io_thread (uint64_t affinity_); + xs::io_thread_t *choose_io_thread (uint64_t affinity_); // Returns reaper thread object. - zmq::object_t *get_reaper (); + xs::object_t *get_reaper (); // Management of inproc endpoints. int register_endpoint (const char *addr_, endpoint_t &endpoint_); - void unregister_endpoints (zmq::socket_base_t *socket_); + void unregister_endpoints (xs::socket_base_t *socket_); endpoint_t find_endpoint (const char *addr_); // Logging related functions. @@ -110,7 +110,7 @@ namespace zmq uint32_t tag; // Sockets belonging to this context. We need the list so that - // we can notify the sockets when zmq_term() is called. The sockets + // we can notify the sockets when xs_term() is called. The sockets // will return ETERM then. typedef array_t sockets_t; sockets_t sockets; @@ -119,7 +119,7 @@ namespace zmq typedef std::vector emtpy_slots_t; emtpy_slots_t empty_slots; - // If true, zmq_term was already called. + // If true, xs_term was already called. bool terminating; // Synchronisation of accesses to global slot-related data: @@ -129,17 +129,17 @@ namespace zmq mutex_t slot_sync; // The reaper thread. - zmq::reaper_t *reaper; + xs::reaper_t *reaper; // I/O threads. - typedef std::vector io_threads_t; + typedef std::vector io_threads_t; io_threads_t io_threads; // Array of pointers to mailboxes for both application and I/O threads. uint32_t slot_count; mailbox_t **slots; - // Mailbox for zmq_term thread. + // Mailbox for xs_term thread. mailbox_t term_mailbox; // List of inproc endpoints within this context. @@ -150,14 +150,14 @@ namespace zmq mutex_t endpoints_sync; // Monitor object attached to the context. - zmq::monitor_t *monitor; + xs::monitor_t *monitor; // Maximum socket ID. static atomic_counter_t max_socket_id; // PUB socket for logging. The socket is shared among all the threads, // thus it is synchronised by a mutex. - zmq::socket_base_t *log_socket; + xs::socket_base_t *log_socket; mutex_t log_sync; ctx_t (const ctx_t&); diff --git a/src/decoder.cpp b/src/decoder.cpp index 48f457f..910d7aa 100644 --- a/src/decoder.cpp +++ b/src/decoder.cpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -28,7 +28,7 @@ #include "wire.hpp" #include "err.hpp" -zmq::decoder_t::decoder_t (size_t bufsize_, int64_t maxmsgsize_) : +xs::decoder_t::decoder_t (size_t bufsize_, int64_t maxmsgsize_) : decoder_base_t (bufsize_), session (NULL), maxmsgsize (maxmsgsize_) @@ -40,18 +40,18 @@ zmq::decoder_t::decoder_t (size_t bufsize_, int64_t maxmsgsize_) : next_step (tmpbuf, 1, &decoder_t::one_byte_size_ready); } -zmq::decoder_t::~decoder_t () +xs::decoder_t::~decoder_t () { int rc = in_progress.close (); errno_assert (rc == 0); } -void zmq::decoder_t::set_session (session_base_t *session_) +void xs::decoder_t::set_session (session_base_t *session_) { session = session_; } -bool zmq::decoder_t::one_byte_size_ready () +bool xs::decoder_t::one_byte_size_ready () { // First byte of size is read. If it is 0xff read 8-byte size. // Otherwise allocate the buffer for message data and read the @@ -67,7 +67,7 @@ bool zmq::decoder_t::one_byte_size_ready () } // in_progress is initialised at this point so in theory we should - // close it before calling zmq_msg_init_size, however, it's a 0-byte + // close it before calling xs_msg_init_size, however, it's a 0-byte // message and thus we can treat it as uninitialised... int rc; if (maxmsgsize >= 0 && (int64_t) (*tmpbuf - 1) > maxmsgsize) { @@ -89,7 +89,7 @@ bool zmq::decoder_t::one_byte_size_ready () return true; } -bool zmq::decoder_t::eight_byte_size_ready () +bool xs::decoder_t::eight_byte_size_ready () { // 8-byte size is read. Allocate the buffer for message body and // read the message data into it. @@ -102,7 +102,7 @@ bool zmq::decoder_t::eight_byte_size_ready () } // in_progress is initialised at this point so in theory we should - // close it before calling zmq_msg_init_size, however, it's a 0-byte + // close it before calling xs_msg_init_size, however, it's a 0-byte // message and thus we can treat it as uninitialised... int rc; if (maxmsgsize >= 0 && (int64_t) (size - 1) > maxmsgsize) { @@ -123,7 +123,7 @@ bool zmq::decoder_t::eight_byte_size_ready () return true; } -bool zmq::decoder_t::flags_ready () +bool xs::decoder_t::flags_ready () { // Store the flags from the wire into the message structure. in_progress.set_flags (tmpbuf [0]); @@ -134,7 +134,7 @@ bool zmq::decoder_t::flags_ready () return true; } -bool zmq::decoder_t::message_ready () +bool xs::decoder_t::message_ready () { // Message is completely read. Push it further and start reading // new message. (in_progress is a 0-byte message after this point.) diff --git a/src/decoder.hpp b/src/decoder.hpp index 4afd018..bed1fc4 100644 --- a/src/decoder.hpp +++ b/src/decoder.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,8 +19,8 @@ along with this program. If not, see . */ -#ifndef __ZMQ_DECODER_HPP_INCLUDED__ -#define __ZMQ_DECODER_HPP_INCLUDED__ +#ifndef __XS_DECODER_HPP_INCLUDED__ +#define __XS_DECODER_HPP_INCLUDED__ #include #include @@ -31,14 +31,14 @@ #include "msg.hpp" #include "stdint.hpp" -namespace zmq +namespace xs { class session_base_t; // Helper base class for decoders that know the amount of data to read // in advance at any moment. Knowing the amount in advance is a property - // of the protocol used. 0MQ framing protocol is based size-prefixed + // of the protocol used. Crossroads framing protocol is based size-prefixed // paradigm, whixh qualifies it to be parsed by this class. // On the other hand, XML-based transports (like XMPP or SOAP) don't allow // for knowing the size of data to read in advance and should use different @@ -186,7 +186,8 @@ namespace zmq const decoder_base_t &operator = (const decoder_base_t&); }; - // Decoder for 0MQ framing protocol. Converts data batches into messages. + // Decoder for Crossroads framing protocol. + // Converts data batches into messages. class decoder_t : public decoder_base_t { @@ -195,7 +196,7 @@ namespace zmq decoder_t (size_t bufsize_, int64_t maxmsgsize_); ~decoder_t (); - void set_session (zmq::session_base_t *session_); + void set_session (xs::session_base_t *session_); private: @@ -204,7 +205,7 @@ namespace zmq bool flags_ready (); bool message_ready (); - zmq::session_base_t *session; + xs::session_base_t *session; unsigned char tmpbuf [8]; msg_t in_progress; diff --git a/src/devpoll.cpp b/src/devpoll.cpp index 0c46d14..12b22ce 100644 --- a/src/devpoll.cpp +++ b/src/devpoll.cpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -20,7 +20,7 @@ */ #include "devpoll.hpp" -#if defined ZMQ_USE_DEVPOLL +#if defined XS_USE_DEVPOLL #include #include @@ -37,27 +37,27 @@ #include "config.hpp" #include "i_poll_events.hpp" -zmq::devpoll_t::devpoll_t () : +xs::devpoll_t::devpoll_t () : stopping (false) { devpoll_fd = open ("/dev/poll", O_RDWR); errno_assert (devpoll_fd != -1); } -zmq::devpoll_t::~devpoll_t () +xs::devpoll_t::~devpoll_t () { worker.stop (); close (devpoll_fd); } -void zmq::devpoll_t::devpoll_ctl (fd_t fd_, short events_) +void xs::devpoll_t::devpoll_ctl (fd_t fd_, short events_) { struct pollfd pfd = {fd_, events_, 0}; ssize_t rc = write (devpoll_fd, &pfd, sizeof pfd); - zmq_assert (rc == sizeof pfd); + xs_assert (rc == sizeof pfd); } -zmq::devpoll_t::handle_t zmq::devpoll_t::add_fd (fd_t fd_, +xs::devpoll_t::handle_t xs::devpoll_t::add_fd (fd_t fd_, i_poll_events *reactor_) { // If the file descriptor table is too small expand it. @@ -86,7 +86,7 @@ zmq::devpoll_t::handle_t zmq::devpoll_t::add_fd (fd_t fd_, return fd_; } -void zmq::devpoll_t::rm_fd (handle_t handle_) +void xs::devpoll_t::rm_fd (handle_t handle_) { assert (fd_table [handle_].valid); @@ -97,45 +97,45 @@ void zmq::devpoll_t::rm_fd (handle_t handle_) adjust_load (-1); } -void zmq::devpoll_t::set_pollin (handle_t handle_) +void xs::devpoll_t::set_pollin (handle_t handle_) { devpoll_ctl (handle_, POLLREMOVE); fd_table [handle_].events |= POLLIN; devpoll_ctl (handle_, fd_table [handle_].events); } -void zmq::devpoll_t::reset_pollin (handle_t handle_) +void xs::devpoll_t::reset_pollin (handle_t handle_) { devpoll_ctl (handle_, POLLREMOVE); fd_table [handle_].events &= ~((short) POLLIN); devpoll_ctl (handle_, fd_table [handle_].events); } -void zmq::devpoll_t::set_pollout (handle_t handle_) +void xs::devpoll_t::set_pollout (handle_t handle_) { devpoll_ctl (handle_, POLLREMOVE); fd_table [handle_].events |= POLLOUT; devpoll_ctl (handle_, fd_table [handle_].events); } -void zmq::devpoll_t::reset_pollout (handle_t handle_) +void xs::devpoll_t::reset_pollout (handle_t handle_) { devpoll_ctl (handle_, POLLREMOVE); fd_table [handle_].events &= ~((short) POLLOUT); devpoll_ctl (handle_, fd_table [handle_].events); } -void zmq::devpoll_t::start () +void xs::devpoll_t::start () { worker.start (worker_routine, this); } -void zmq::devpoll_t::stop () +void xs::devpoll_t::stop () { stopping = true; } -void zmq::devpoll_t::loop () +void xs::devpoll_t::loop () { while (!stopping) { @@ -152,7 +152,7 @@ void zmq::devpoll_t::loop () // Wait for events. // On Solaris, we can retrieve no more then (OPEN_MAX - 1) events. poll_req.dp_fds = &ev_buf [0]; -#if defined ZMQ_HAVE_SOLARIS +#if defined XS_HAVE_SOLARIS poll_req.dp_nfds = std::min ((int) max_io_events, OPEN_MAX - 1); #else poll_req.dp_nfds = max_io_events; @@ -182,7 +182,7 @@ void zmq::devpoll_t::loop () } } -void zmq::devpoll_t::worker_routine (void *arg_) +void xs::devpoll_t::worker_routine (void *arg_) { ((devpoll_t*) arg_)->loop (); } diff --git a/src/devpoll.hpp b/src/devpoll.hpp index 382be0f..4f210c4 100644 --- a/src/devpoll.hpp +++ b/src/devpoll.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,12 +19,12 @@ along with this program. If not, see . */ -#ifndef __ZMQ_DEVPOLL_HPP_INCLUDED__ -#define __ZMQ_DEVPOLL_HPP_INCLUDED__ +#ifndef __XS_DEVPOLL_HPP_INCLUDED__ +#define __XS_DEVPOLL_HPP_INCLUDED__ // poller.hpp decides which polling mechanism to use. #include "poller.hpp" -#if defined ZMQ_USE_DEVPOLL +#if defined XS_USE_DEVPOLL #include @@ -32,7 +32,7 @@ #include "thread.hpp" #include "poller_base.hpp" -namespace zmq +namespace xs { struct i_poll_events; @@ -49,7 +49,7 @@ namespace zmq ~devpoll_t (); // "poller" concept. - handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_); + handle_t add_fd (fd_t fd_, xs::i_poll_events *events_); void rm_fd (handle_t handle_); void set_pollin (handle_t handle_); void reset_pollin (handle_t handle_); @@ -72,7 +72,7 @@ namespace zmq struct fd_entry_t { short events; - zmq::i_poll_events *reactor; + xs::i_poll_events *reactor; bool valid; bool accepted; }; diff --git a/src/dist.cpp b/src/dist.cpp index d220c43..24f1132 100644 --- a/src/dist.cpp +++ b/src/dist.cpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2011 250bpm s.r.o. + Copyright (c) 2011-2012 250bpm s.r.o. Copyright (c) 2011 VMware, Inc. Copyright (c) 2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -25,7 +25,7 @@ #include "msg.hpp" #include "likely.hpp" -zmq::dist_t::dist_t () : +xs::dist_t::dist_t () : matching (0), active (0), eligible (0), @@ -33,12 +33,12 @@ zmq::dist_t::dist_t () : { } -zmq::dist_t::~dist_t () +xs::dist_t::~dist_t () { - zmq_assert (pipes.empty ()); + xs_assert (pipes.empty ()); } -void zmq::dist_t::attach (pipe_t *pipe_) +void xs::dist_t::attach (pipe_t *pipe_) { // If we are in the middle of sending a message, we'll add new pipe // into the list of eligible pipes. Otherwise we add it to the list @@ -56,7 +56,7 @@ void zmq::dist_t::attach (pipe_t *pipe_) } } -void zmq::dist_t::match (pipe_t *pipe_) +void xs::dist_t::match (pipe_t *pipe_) { // If pipe is already matching do nothing. if (pipes.index (pipe_) < matching) @@ -71,12 +71,12 @@ void zmq::dist_t::match (pipe_t *pipe_) matching++; } -void zmq::dist_t::unmatch () +void xs::dist_t::unmatch () { matching = 0; } -void zmq::dist_t::terminated (pipe_t *pipe_) +void xs::dist_t::terminated (pipe_t *pipe_) { // Remove the pipe from the list; adjust number of matching, active and/or // eligible pipes accordingly. @@ -89,7 +89,7 @@ void zmq::dist_t::terminated (pipe_t *pipe_) pipes.erase (pipe_); } -void zmq::dist_t::activated (pipe_t *pipe_) +void xs::dist_t::activated (pipe_t *pipe_) { // Move the pipe from passive to eligible state. pipes.swap (pipes.index (pipe_), eligible); @@ -103,13 +103,13 @@ void zmq::dist_t::activated (pipe_t *pipe_) } } -int zmq::dist_t::send_to_all (msg_t *msg_, int flags_) +int xs::dist_t::send_to_all (msg_t *msg_, int flags_) { matching = active; return send_to_matching (msg_, flags_); } -int zmq::dist_t::send_to_matching (msg_t *msg_, int flags_) +int xs::dist_t::send_to_matching (msg_t *msg_, int flags_) { // Is this end of a multipart message? bool msg_more = msg_->flags () & msg_t::more ? true : false; @@ -126,14 +126,14 @@ int zmq::dist_t::send_to_matching (msg_t *msg_, int flags_) return 0; } -void zmq::dist_t::distribute (msg_t *msg_, int flags_) +void xs::dist_t::distribute (msg_t *msg_, int flags_) { // If there are no matching pipes available, simply drop the message. if (matching == 0) { int rc = msg_->close (); errno_assert (rc == 0); rc = msg_->init (); - zmq_assert (rc == 0); + xs_assert (rc == 0); return; } @@ -165,12 +165,12 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_) errno_assert (rc == 0); } -bool zmq::dist_t::has_out () +bool xs::dist_t::has_out () { return true; } -bool zmq::dist_t::write (pipe_t *pipe_, msg_t *msg_) +bool xs::dist_t::write (pipe_t *pipe_, msg_t *msg_) { if (!pipe_->write (msg_)) { pipes.swap (pipes.index (pipe_), matching - 1); diff --git a/src/dist.hpp b/src/dist.hpp index be86ab2..a16ca7b 100644 --- a/src/dist.hpp +++ b/src/dist.hpp @@ -1,15 +1,15 @@ /* - Copyright (c) 2011 250bpm s.r.o. + Copyright (c) 2011-2012 250bpm s.r.o. Copyright (c) 2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -18,15 +18,15 @@ along with this program. If not, see . */ -#ifndef __ZMQ_DIST_HPP_INCLUDED__ -#define __ZMQ_DIST_HPP_INCLUDED__ +#ifndef __XS_DIST_HPP_INCLUDED__ +#define __XS_DIST_HPP_INCLUDED__ #include #include "array.hpp" #include "pipe.hpp" -namespace zmq +namespace xs { class pipe_t; @@ -42,26 +42,26 @@ namespace zmq ~dist_t (); // Adds the pipe to the distributor object. - void attach (zmq::pipe_t *pipe_); + void attach (xs::pipe_t *pipe_); // Activates pipe that have previously reached high watermark. - void activated (zmq::pipe_t *pipe_); + void activated (xs::pipe_t *pipe_); // Mark the pipe as matching. Subsequent call to send_to_matching // will send message also to this pipe. - void match (zmq::pipe_t *pipe_); + void match (xs::pipe_t *pipe_); // Mark all pipes as non-matching. void unmatch (); // Removes the pipe from the distributor object. - void terminated (zmq::pipe_t *pipe_); + void terminated (xs::pipe_t *pipe_); // Send the message to the matching outbound pipes. - int send_to_matching (zmq::msg_t *msg_, int flags_); + int send_to_matching (xs::msg_t *msg_, int flags_); // Send the message to all the outbound pipes. - int send_to_all (zmq::msg_t *msg_, int flags_); + int send_to_all (xs::msg_t *msg_, int flags_); bool has_out (); @@ -69,13 +69,13 @@ namespace zmq // Write the message to the pipe. Make the pipe inactive if writing // fails. In such a case false is returned. - bool write (zmq::pipe_t *pipe_, zmq::msg_t *msg_); + bool write (xs::pipe_t *pipe_, xs::msg_t *msg_); // Put the message to all active pipes. - void distribute (zmq::msg_t *msg_, int flags_); + void distribute (xs::msg_t *msg_, int flags_); // List of outbound pipes. - typedef array_t pipes_t; + typedef array_t pipes_t; pipes_t pipes; // Number of all the pipes to send the next message to. diff --git a/src/encoder.cpp b/src/encoder.cpp index 030b3ef..c1397fe 100644 --- a/src/encoder.cpp +++ b/src/encoder.cpp @@ -1,17 +1,17 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2011 VMware, Inc. Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -25,7 +25,7 @@ #include "likely.hpp" #include "wire.hpp" -zmq::encoder_t::encoder_t (size_t bufsize_) : +xs::encoder_t::encoder_t (size_t bufsize_) : encoder_base_t (bufsize_), session (NULL) { @@ -36,18 +36,18 @@ zmq::encoder_t::encoder_t (size_t bufsize_) : next_step (NULL, 0, &encoder_t::message_ready, true); } -zmq::encoder_t::~encoder_t () +xs::encoder_t::~encoder_t () { int rc = in_progress.close (); errno_assert (rc == 0); } -void zmq::encoder_t::set_session (session_base_t *session_) +void xs::encoder_t::set_session (session_base_t *session_) { session = session_; } -bool zmq::encoder_t::size_ready () +bool xs::encoder_t::size_ready () { // Write message body into the buffer. next_step (in_progress.data (), in_progress.size (), @@ -55,7 +55,7 @@ bool zmq::encoder_t::size_ready () return true; } -bool zmq::encoder_t::message_ready () +bool xs::encoder_t::message_ready () { // Destroy content of the old message. int rc = in_progress.close (); diff --git a/src/encoder.hpp b/src/encoder.hpp index f521b6b..93efbb8 100644 --- a/src/encoder.hpp +++ b/src/encoder.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,8 +19,8 @@ along with this program. If not, see . */ -#ifndef __ZMQ_ENCODER_HPP_INCLUDED__ -#define __ZMQ_ENCODER_HPP_INCLUDED__ +#ifndef __XS_ENCODER_HPP_INCLUDED__ +#define __XS_ENCODER_HPP_INCLUDED__ #include #include @@ -30,7 +30,7 @@ #include "err.hpp" #include "msg.hpp" -namespace zm