Skip to content

Commit

Permalink
iox-eclipse-iceoryx#2067 Support move-only types in the LockFreeQueue
Browse files Browse the repository at this point in the history
Signed-off-by: Graham Palmer <[email protected]>
  • Loading branch information
Graham Palmer committed Oct 27, 2023
1 parent a49f57c commit a6f2d88
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

**Bugfixes:**

- LockFreeQueue fails to support move-only types [\#2067](https://github.com/eclipse-iceoryx/iceoryx/issues/2067)
- FreeBSD CI build is broken [\#1338](https://github.com/eclipse-iceoryx/iceoryx/issues/1338)
- High CPU load in blocked publisher is reduced by introducing smart busy loop waiting (adaptive_wait) [\#1347](https://github.com/eclipse-iceoryx/iceoryx/issues/1347)
- Compile Error : iceoryx_dds/Mempool.hpp: No such file or directory [\#1364](https://github.com/eclipse-iceoryx/iceoryx/issues/1364)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2023 by Latitude AI. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -105,7 +106,7 @@ iox::optional<ElementType> LockFreeQueue<ElementType, Capacity>::pushImpl(T&& va

// if we removed from a full queue via popIfFull it might not be full anymore when a concurrent pop occurs

writeBufferAt(index, value); //&& version is called due to explicit conversion via std::move
writeBufferAt(index, std::forward<T>(value));

m_usedIndices.push(index);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2023 by Latitude AI. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -213,7 +214,7 @@ iox::optional<ElementType> ResizeableLockFreeQueue<ElementType, MaxCapacity>::pu

// if we removed from a full queue via popIfFull it might not be full anymore when a concurrent pop occurs

Base::writeBufferAt(index, value);
Base::writeBufferAt(index, std::forward<T>(value));

Base::m_usedIndices.push(index);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2023 by Latitude AI. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,6 +40,14 @@ struct Integer
{
}

// Delete copy constructor to ensure that the queue supports move-only types.
Integer(const Integer&) = delete;
Integer& operator=(const Integer&) = delete;
Integer(Integer&&) = default;
Integer& operator=(Integer&&) = default;

~Integer() = default;

int value{0};

// so that it behaves like an int for comparison purposes
Expand Down

0 comments on commit a6f2d88

Please sign in to comment.