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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,31 @@ jobs:
cmake --preset coverage
cmake --build --preset coverage
ctest --preset coverage

android:
runs-on: ubuntu-latest
strategy:
matrix:
abi: [arm64-v8a, armeabi-v7a]
steps:
- uses: actions/checkout@v4
- name: Configure and build (Android ${{ matrix.abi }})
run: |
NDK_TOOLCHAIN="${ANDROID_NDK_HOME:-${ANDROID_NDK_LATEST_HOME}}/build/cmake/android.toolchain.cmake"
cmake -B build-android -G Ninja \
-DCMAKE_TOOLCHAIN_FILE="${NDK_TOOLCHAIN}" \
-DANDROID_ABI="${{ matrix.abi }}" \
-DANDROID_PLATFORM=android-24
cmake --build build-android

ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Configure and build (iOS simulator)
run: |
cmake -B build-ios \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_SYSROOT=iphonesimulator \
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO
cmake --build build-ios --config Release
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.24...4.3)

project(SPSCQueue
VERSION 2.0.0
VERSION 2.0.1
HOMEPAGE_URL "https://github.com/rigtorp/SPSCQueue"
LANGUAGES CXX
)
Expand Down Expand Up @@ -43,7 +43,7 @@ if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
)
endfunction()

if(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
spscqueue_executable(SPSCQueueBenchmark src/SPSCQueueBenchmark.cpp)
find_library(RTE_RING_LIBRARY rte_ring)
if(RTE_RING_LIBRARY)
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
pkgs = nixpkgs.legacyPackages.${system};
benchmark = pkgs.stdenv.mkDerivation {
pname = "spscqueue-benchmark";
version = "2.0.0";
version = "2.0.1";
src = ./.;

hardeningDisable = ["all"];
Expand Down
12 changes: 12 additions & 0 deletions src/SPSCQueueBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <algorithm>
#include <atomic>
#include <cerrno>
#include <chrono>
#include <cstdlib>
#include <cstring>
Expand All @@ -16,6 +17,10 @@
#include <thread>
#include <vector>

#if defined(__ANDROID__)
#include <sched.h>
#endif

#if __has_include(<boost/lockfree/spsc_queue.hpp> )
#include <boost/lockfree/spsc_queue.hpp>
#endif
Expand Down Expand Up @@ -69,13 +74,20 @@ void pinThread(int cpu) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(static_cast<size_t>(cpu), &cpuset);
#if defined(__ANDROID__)
if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset) != 0) {
std::cerr << "sched_setaffinity: " << std::strerror(errno) << std::endl;
std::exit(EXIT_FAILURE);
}
#else
const int error =
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (error != 0) {
std::cerr << "pthread_setaffinity_np: " << std::strerror(error)
<< std::endl;
std::exit(EXIT_FAILURE);
}
#endif
}

template <typename Consumer, typename Producer>
Expand Down
Loading