Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions .github/workflows/cmake-superbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)
project(azmq-super-build)

#options
Expand All @@ -23,12 +23,18 @@ endif ()

include(ExternalProject)

set(BOOST_177 "https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2")
set(BOOST_176 "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2")
set(BOOST_174 "https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.bz2")
set(BOOST_172 "https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2")
set(BOOST_170 "https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.bz2")
set(BOOST_168 "https://boostorg.jfrog.io/artifactory/main/release/1.68.0/source/boost_1_68_0.tar.bz2")

set(BOOST_189 "https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.bz2")
set(BOOST_187 "https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.bz2")
set(BOOST_186 "https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2")
set(BOOST_184 "https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.bz2")
set(BOOST_181 "https://archives.boost.io/release/1.81.0/source/boost_1_81_0.tar.bz2")
set(BOOST_177 "https://archives.boost.io/release/1.77.0/source/boost_1_77_0.tar.bz2")
set(BOOST_176 "https://archives.boost.io/release/1.76.0/source/boost_1_76_0.tar.bz2")
set(BOOST_174 "https://archives.boost.io/release/1.74.0/source/boost_1_74_0.tar.bz2")
set(BOOST_172 "https://archives.boost.io/release/1.72.0/source/boost_1_72_0.tar.bz2")
set(BOOST_170 "https://archives.boost.io/release/1.70.0/source/boost_1_70_0.tar.bz2")
set(BOOST_168 "https://archives.boost.io/release/1.68.0/source/boost_1_68_0.tar.bz2")

set(DEVROOT ${CMAKE_BINARY_DIR}/devroot)

Expand Down Expand Up @@ -76,13 +82,19 @@ if (NOT (BOOST_URL STREQUAL "system"))
INSTALL_DIR ${DEVROOT}
CONFIGURE_COMMAND ./bootstrap.sh --prefix=<INSTALL_DIR>
BUILD_COMMAND ""
INSTALL_COMMAND ./b2 install --prefix=<INSTALL_DIR> -j${CPU_COUNT})
INSTALL_COMMAND ./b2 install --prefix=<INSTALL_DIR> -j${CPU_COUNT} --warnings-as-errors=off --without-python --without-math)
list(APPEND LIBS boost)
endif ()

cmake_policy(GET CMP0167 _cmp0167_value)
if(_cmp0167_value)
set(_policy_arg "-DCMAKE_POLICY_DEFAULT_CMP0167=${_cmp0167_value}")
message(STATUS " Setting superbuild CMP0167 to ${_cmp0167_value} ")
endif()

ExternalProject_Add(
azmq
DEPENDS ${LIBS}
CMAKE_ARGS ${CMAKE_ARGS} -D AZMQ_BUILD_TESTS=YES
CMAKE_ARGS ${CMAKE_ARGS} -D AZMQ_BUILD_TESTS=YES ${_policy_arg}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../..
TEST_BEFORE_INSTALL YES)
141 changes: 96 additions & 45 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,126 @@ on:
pull_request:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- {
name: "ubuntu22",
os: ubuntu-22.04,
boost_url: system,
zmq_tag: system,
system_packages: "libboost-all-dev libzmq3-dev ",
cc: "gcc",
cxx: "g++",
}
- {
name: "ubuntu20 stock",
os: ubuntu-20.04,
boost_url: system,
zmq_tag: system,
system_packages: "libboost-all-dev libzmq3-dev ",
cc: "gcc",
cxx: "g++",
}
- {
name: "macos12 ",
os: macos-12,
boost_url: system,
zmq_tag: system,
system_packages: "zmq boost",
cc: "clang",
cxx: "clang++",
}
- {
name: "macos11 ",
os: macos-11,
boost_url: system,
zmq_tag: system,
system_packages: "zmq boost",
cc: "clang",
cxx: "clang++",
}
config:
- os: ubuntu-24.04
family: ubuntu
cc: gcc
cxx: g++
- os: ubuntu-22.04
family: ubuntu
cc: gcc
cxx: g++
- os: macos-26
family: macos
cc: clang
cxx: clang++
- os: macos-15
family: macos
cc: clang
cxx: clang++
- os: macos-14
family: macos
cc: clang
cxx: clang++
- os: macos-13
family: macos
cc: clang
cxx: clang++
boost:
- url: system
system_packages_ubuntu: libboost-all-dev
system_packages_macos: boost
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
- url: BOOST_189
system_packages_ubuntu:
system_packages_macos:
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
- url: BOOST_187
system_packages_ubuntu:
system_packages_macos:
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
- url: BOOST_184
system_packages_ubuntu:
system_packages_macos:
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
- url: BOOST_181
system_packages_ubuntu:
system_packages_macos:
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
- url: BOOST_176
system_packages_ubuntu:
system_packages_macos:
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
- url: BOOST_174
system_packages_ubuntu:
system_packages_macos:
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
- url: BOOST_168
system_packages_ubuntu:
system_packages_macos:
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=OLD
zmq:
- tag: system
system_packages_ubuntu: libzmq3-dev
system_packages_macos: zmq
exclude:
- config:
family: macos
boost:
url: BOOST_176
- config:
family: macos
boost:
url: BOOST_174
- config:
family: macos
boost:
url: BOOST_168
- config:
os: macos-14
boost:
url: BOOST_181

runs-on: ${{ matrix.config.os }}

env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
CTEST_OUTPUT_ON_FAILURE: 1
PACKAGES: ${{ matrix.config.system_packages }}
PACKAGES_UBUNTU: ${{ matrix.boost.system_packages_ubuntu }} ${{ matrix.zmq.system_packages_ubuntu }}
PACKAGES_MACOS: ${{ matrix.boost.system_packages_macos }} ${{ matrix.zmq.system_packages_macos }}
CONFIG_OS: ${{ matrix.config.os }}
MATRIX: ${{ toJson(matrix) }}

steps:
- uses: actions/checkout@v3
- name: buildtools on ubuntu
if: startsWith(matrix.config.name, 'ubuntu')
if: ${{ startsWith(matrix.config.os, 'ubuntu') }}
shell: bash
run: |
if [ -n "$PACKAGES" ]; then
sudo apt-get install -y $PACKAGES
PACKAGES_UBUNTU=$(echo $PACKAGES_UBUNTU | sed 's/^[ ]*//;s/[ ]*$//')
if [ -n "$PACKAGES_UBUNTU" ]; then
sudo apt-get update && sudo apt-get install -y $PACKAGES_UBUNTU
fi
- name: buildtools on macos
if: startsWith(matrix.config.name, 'macos') && matrix.config.*.system_packages
if: ${{ startsWith(matrix.config.os, 'macos') }}
shell: bash
run: |
if [ -n "$PACKAGES" ]; then
brew install $PACKAGES
PACKAGES_MACOS=$(echo $PACKAGES_MACOS | sed 's/^[ ]*//;s/[ ]*$//')
if [ -n "$PACKAGES_MACOS" ]; then
brew install $PACKAGES_MACOS
fi
- name: build
shell: bash
run: |
cmake -DBOOST_URL=${{matrix.config.boost_url}} -DZMQ_TAG=${{matrix.config.zmq_tag}} -S .github/workflows/cmake-superbuild -B build
cmake -DBOOST_URL=${{matrix.boost.url}} -DZMQ_TAG=${{matrix.zmq.tag}} ${{matrix.boost.extra_cmake_args}} -S .github/workflows/cmake-superbuild -B build
cmake --build build
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
*.a
*.pyc
build/*
build_*/*

# Other files
.devcontainer
.vscode
.DS_Store
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Thomas W Rodgers <rodgert@twrodgers.com>
Andrey Upadyshev <oliora@gmail.com>
Tim Blechmann <tim@klingt.org>
Adam Boseley <adam.boseley@gmail.com>
Juan Pablo Pino <jp.pinob@gmail.com>
4 changes: 2 additions & 2 deletions AzmqCPack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ in general, and Asio in particular.

The main abstraction exposed by the library is azmq::socket which
provides an Asio style socket interface to the underlying zeromq socket
and interfaces with Asio's io_service(). The socket implementation
participates in the io_service's reactor for asynchronous IO and
and interfaces with Asio's io_context(). The socket implementation
participates in the io_context's reactor for asynchronous IO and
may be freely mixed with other Asio socket types (raw TCP/UDP/Serial/etc.).")
set(CPACK_PACKAGE_VERSION "1.1.0")

Expand Down
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16.3...3.25)
# -- v3.16.3 is the default version in the current ubuntu lts release
cmake_minimum_required(VERSION 3.22.1...3.29.2)
# -- v3.22.1 is the default version in the current ubuntu lts release

project(azmq VERSION 1.1.0 LANGUAGES CXX)

Expand All @@ -21,13 +21,18 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# --- dependencies --
find_package(
Boost 1.68
COMPONENTS system
date_time
COMPONENTS date_time
thread
chrono
random
REQUIRED)

# Try to find Boost::system
find_package(Boost COMPONENTS system)
if (NOT Boost_SYSTEM_FOUND)
message(WARNING "Boost::system not found, some examples may not compile")
endif()

include(FindAzmqLibzmq.cmake)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
Expand All @@ -37,7 +42,7 @@ find_package(Threads REQUIRED)
add_library(${PROJECT_NAME} INTERFACE)
add_library(Azmq::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME} INTERFACE Azmq::libzmq Boost::boost ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} INTERFACE Azmq::libzmq Boost::boost ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:include>")

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ in general, and Asio in particular.

The main abstraction exposed by the library is azmq::socket which
provides an Asio style socket interface to the underlying zeromq socket
and interfaces with Asio's io_service(). The socket implementation
participates in the io_service's reactor for asynchronous IO and
and interfaces with Asio's io_context(). The socket implementation
participates in the io_context's reactor for asynchronous IO and
may be freely mixed with other Asio socket types (raw TCP/UDP/Serial/etc.).

## Building and installation
Expand All @@ -29,7 +29,7 @@ which supports C++11. Currently this has been tested with -
* Microsoft Visual Studio 2013 on Windows Server 2008 R2

Library dependencies are -
* Boost 1.48 or later
* Boost 1.68 or later
* ZeroMQ 4.0.x

Tests and example code require -
Expand Down Expand Up @@ -82,13 +82,13 @@ http://zeromq.org/intro:read-the-manual
namespace asio = boost::asio;

int main(int argc, char** argv) {
asio::io_service ios;
azmq::sub_socket subscriber(ios);
asio::io_context ioc;
azmq::sub_socket subscriber(ioc);
subscriber.connect("tcp://192.168.55.112:5556");
subscriber.connect("tcp://192.168.55.201:7721");
subscriber.set_option(azmq::socket::subscribe("NASDAQ"));

azmq::pub_socket publisher(ios);
azmq::pub_socket publisher(ioc);
publisher.bind("ipc://nasdaq-feed");

std::array<char, 256> buf;
Expand Down
21 changes: 10 additions & 11 deletions azmq/actor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "socket.hpp"
#include "detail/actor_service.hpp"

#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>

#include <functional>

Expand All @@ -25,7 +25,7 @@ AZMQ_V1_INLINE_NAMESPACE_BEGIN
using last_error = detail::actor_service::last_error;

/** \brief create an actor bound to one end of a pipe (pair of inproc sockets)
* \param peer io_service to associate the peer (caller) end of the pipe
* \param peer io_context to associate the peer (caller) end of the pipe
* \param f Function accepting socket& as the first parameter and a
* number of additional args
* \returns peer socket
Expand All @@ -35,15 +35,15 @@ AZMQ_V1_INLINE_NAMESPACE_BEGIN
* will be attached to the lifetime of the returned socket and will run
* until it is destroyed.
*
* \remark Each actor has an associated io_service and the supplied socket
* will be created on this io_service. The actor may access this by calling
* get_io_service() on the supplied socket.
* \remark Each actor has an associated io_context and the supplied socket
* will be created on this io_context. The actor may access this by calling
* get_io_context() on the supplied socket.
*
* \remark The associated io_service is configured to stop the spawned actor
* \remark The associated io_context is configured to stop the spawned actor
* on SIG_KILL and SIG_TERM.
*
* \remark Termination:
* well behaved actors should ultimately call run() on the io_service
* well behaved actors should ultimately call run() on the io_context
* associated with the supplied socket. This allows the 'client' end of
* the socket's lifetime to cleanly signal termination. If for some
* reason, this is not possible, the caller should set the 'detached'
Expand All @@ -54,20 +54,20 @@ AZMQ_V1_INLINE_NAMESPACE_BEGIN
* message.
*
* Also note, the default signal handling for the background thread is
* designed to call stop() on the associated io_service, so not calling
* designed to call stop() on the associated io_context, so not calling
* run() in your handler means you are responsible for catching these
* signals in some other way.
*/
template<typename Function, typename... Args>
socket spawn(boost::asio::io_service & peer, bool defer_start, Function && f, Args&&... args) {
socket spawn(boost::asio::io_context & peer, bool defer_start, Function && f, Args&&... args) {
auto& t = boost::asio::use_service<detail::actor_service>(peer);
return t.make_pipe(defer_start, std::bind(std::forward<Function>(f),
std::placeholders::_1,
std::forward<Args>(args)...));
}

template<typename Function, typename... Args>
socket spawn(boost::asio::io_service & peer, Function && f, Args&&... args) {
socket spawn(boost::asio::io_context & peer, Function && f, Args&&... args) {
auto& t = boost::asio::use_service<detail::actor_service>(peer);
return t.make_pipe(false, std::bind(std::forward<Function>(f),
std::placeholders::_1,
Expand All @@ -78,4 +78,3 @@ AZMQ_V1_INLINE_NAMESPACE_END
} // namespace actor
} // namespace azmq
#endif // AZMQ_ACTOR_HPP_

Loading
Loading