## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 3;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

Name:           atomic-queue
Version:        1.6.5
Release:        %autorelease
Summary:        C++ lockless queue

# SPDX
License:        MIT
URL:            https://github.com/max0x7ba/atomic_queue
Source:         %{url}/archive/v%{version}/atomic_queue-%{version}.tar.gz

# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch:    %{ix86}

BuildRequires:  gcc-c++
BuildRequires:  meson
BuildRequires:  boost-devel

# No compiled binaries are installed, so this would be empty.
%global debug_package %{nil}

%global common_description %{expand:
C++14 multiple-producer-multiple-consumer lockless queues based on circular
buffer with std::atomic.

It has been developed, tested and benchmarked on Linux, but should support any
C++14 platforms which implement std::atomic.

The main design principle these queues follow is minimalism: the bare minimum
of atomic operations, fixed size buffer, value semantics.

These qualities are also limitations:

  • The maximum queue size must be set at compile time or construction time.
    The circular buffer side-steps the memory reclamation problem inherent in
    linked-list based queues for the price of fixed buffer size. See Effective
    memory reclamation for lock-free data structures in C++ for more details.
    Fixed buffer size may not be that much of a limitation, since once the
    queue gets larger than the maximum expected size that indicates a problem
    that elements aren’t processed fast enough, and if the queue keeps growing
    it may eventually consume all available memory which may affect the entire
    system, rather than the problematic process only. The only apparent
    inconvenience is that one has to do an upfront back-of-the-envelope
    calculation on what would be the largest expected/acceptable queue size.
  • There are no OS-blocking push/pop functions. This queue is designed for
    ultra-low-latency scenarios and using an OS blocking primitive would be
    sacrificing push-to-pop latency. For lowest possible latency one cannot
    afford blocking in the OS kernel because the wake-up latency of a blocked
    thread is about 1-3 microseconds, whereas this queue’s round-trip time can
    be as low as 150 nanoseconds.

Ultra-low-latency applications need just that and nothing more. The minimalism
pays off, see the throughput and latency benchmarks.

Available containers are:

  • AtomicQueue - a fixed size ring-buffer for atomic elements.
  • OptimistAtomicQueue - a faster fixed size ring-buffer for atomic elements
    which busy-waits when empty or full.
  • AtomicQueue2 - a fixed size ring-buffer for non-atomic elements.
  • OptimistAtomicQueue2 - a faster fixed size ring-buffer for non-atomic
    elements which busy-waits when empty or full.

These containers have corresponding AtomicQueueB, OptimistAtomicQueueB,
AtomicQueueB2, OptimistAtomicQueueB2 versions where the buffer size is
specified as an argument to the constructor.

Totally ordered mode is supported. In this mode consumers receive messages in
the same FIFO order the messages were posted. This mode is supported for push
and pop functions, but for not the try_ versions. On Intel x86 the totally
ordered mode has 0 cost, as of 2019.

Single-producer-single-consumer mode is supported. In this mode, no
read-modify-write instructions are necessary, only the atomic loads and stores.
That improves queue throughput significantly.

Move-only queue element types are fully supported. For example, a queue of
std::unique_ptr<T> elements would be AtomicQueue2B<std::unique_ptr<T>> or
AtomicQueue2<std::unique_ptr<T>, CAPACITY>.}

%description %{common_description}


%package devel
Summary:        Development files for %{name}
BuildArch:      noarch

# Header-only library
Provides:       %{name}-static = %{version}-%{release}

%description devel %{common_description}

The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%prep
%autosetup -n atomic_queue-%{version}


%conf
%meson -Dbenchmarks=false


%build
%meson_build


%install
# Upstream does not install with meson. Just copy the headers.
install -d '%{buildroot}%{_includedir}'
cp -rvp include/atomic_queue '%{buildroot}%{_includedir}/'


%check
%meson_test --verbose
%{_vpath_builddir}/example


%files devel
%license LICENSE
%doc README.md
# We do NOT package “html”, which contains benchmark results, because it loads
# a Google Analytics script.

%{_includedir}/atomic_queue/


%changelog
## START: Generated by rpmautospec
* Thu Oct 31 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.5-2
- Invoke %%meson in %%conf rather than in %%build

* Thu Oct 03 2024 Packit <hello@packit.dev> - 1.6.5-1
- Update to 1.6.5 upstream release
- Resolves: rhbz#2316270

* Mon Jul 22 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.4-1
- Update to 1.6.4 (close RHBZ#2299261)

* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Mon Mar 04 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.3-1
- Update to 1.6.3: Fixes C++20 compile errors

* Mon Mar 04 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.2-1
- Update to 1.6.2

* Wed Feb 14 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.1-1
- [packit] 1.6.1 upstream release

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Thu Nov 16 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5-1
- Update to 1.5 (close RHBZ#2249919)

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Sun Apr 02 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.4-1
- Update to 1.4 (close RHBZ#2183486)

* Sat Feb 25 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.1-1
- Update to 1.1 (close RHBZ#2173288)

* Wed Jan 18 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Mon Dec 19 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0-8
- Indicate dirs. in files list with trailing slashes

* Mon Dec 19 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0-7
- Leaf package: remove i686 support

* Sun Jul 31 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0-6
- Confirm that License is SPDX MIT (no License field change)

* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Dec 16 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0-3
- Let the devel subpackage be noarch

* Thu Dec 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0-2
- Fix release number—no longer a pre-release

* Thu Dec 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0-0.1
- Update to 1.0 (close RHBZ#2030645)

* Fri Oct 22 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0-0.6
- Update to 7013a8b (support up to 256 byte cache lines)

* Wed Oct 20 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0-0.5
- Update to ee3d91c: fix RHBZ#1994598, fix RHBZ#1994599
- Enable verbose test output
- Run the example as an additional test

* Tue Oct 19 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0-0.4
- Update to commit dfd2cbe

* Fri Sep 24 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0-0.3
- We really don’t need to adjust the C++ standard for the tests

* Mon Aug 16 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0-0.2
- Fix an long line in the -devel package description

* Mon Aug 16 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0-0.1
- Initial package
## END: Generated by rpmautospec