Skip to content

iceoryx_posh/internal/mepoo/shm_safe_unmanaged_chunk.hpp🔗

Namespaces🔗

Name
iox
iox::mepoo
Mepoo Component Description.

Classes🔗

Name
class iox::mepoo::ShmSafeUnmanagedChunk
This class to safely store a chunk in shared memory. To be able to do so, torn writes/reads need to prevented, since they create Frankenstein objects. Therefore, the class must not be larger than 64 bits and trivially copy-able in case an application dies while writing this and RouDi needs to clean up.

Source code🔗

// Copyright (c) 2021 by Apex.AI Inc. 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.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_POSH_MEPOO_SHM_SAFE_UNMANAGED_CHUNK_HPP
#define IOX_POSH_MEPOO_SHM_SAFE_UNMANAGED_CHUNK_HPP

#include "iceoryx_posh/internal/mepoo/shared_chunk.hpp"
#include "iceoryx_utils/internal/relocatable_pointer/relative_pointer_data.hpp"

namespace iox
{
namespace mepoo
{
class ShmSafeUnmanagedChunk
{
  public:
    ShmSafeUnmanagedChunk() noexcept = default;

    ShmSafeUnmanagedChunk(SharedChunk chunk) noexcept;

    SharedChunk releaseToSharedChunk() noexcept;

    SharedChunk cloneToSharedChunk() noexcept;

    bool isLogicalNullptr() const noexcept;

    ChunkHeader* getChunkHeader() noexcept;

    const ChunkHeader* getChunkHeader() const noexcept;

    bool isNotLogicalNullptrAndHasNoOtherOwners() const noexcept;

  private:
    rp::RelativePointerData m_chunkManagement;
};

} // namespace mepoo
} // namespace iox

#endif // IOX_POSH_MEPOO_SHM_SAFE_UNMANAGED_CHUNK_HPP

Updated on 17 June 2021 at 11:15:27 CEST