Skip to content

Commit

Permalink
Merge pull request #2120 from elBoberido/iox-1391-move-hoofs-header-f…
Browse files Browse the repository at this point in the history
…rom-legacy-path-to-module-path-part-5

iox-#1391 Move multiple classes to new module path
  • Loading branch information
elBoberido authored Dec 7, 2023
2 parents 6303f2e + e2ab4c0 commit e0f686e
Show file tree
Hide file tree
Showing 59 changed files with 326 additions and 277 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++14
Standard: c++17
TabWidth: 4
UseTab: Never
...
30 changes: 16 additions & 14 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@
auto semaphore = iox::posix::Semaphore::create(iox::posix::CreateUnnamedSingleProcessSemaphore, 0);

// after
#include "iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp"
#include "iox/unnamed_semaphore.hpp"

iox::optional<iox::posix::UnnamedSemaphore> semaphore;
auto result = iox::posix::UnnamedSemaphoreBuilder()
iox::optional<iox::UnnamedSemaphore> semaphore;
auto result = iox::UnnamedSemaphoreBuilder()
.initialValue(0U)
.isInterProcessCapable(true)
.create(semaphore);
Expand All @@ -250,10 +250,10 @@
S_IRUSR | S_IWUSR,
0);
// after
#include "iceoryx_hoofs/posix_wrapper/named_semaphore.hpp"
#include "iox/named_semaphore.hpp"

iox::optional<iox::posix::NamedSemaphore> semaphore;
auto result = iox::posix::NamedSemaphoreBuilder()
iox::optional<iox::NamedSemaphore> semaphore;
auto result = iox::NamedSemaphoreBuilder()
.name("mySemaphoreName")
.openMode(iox::OpenMode::OPEN_OR_CREATE)
.permissions(iox::perms::owner_all)
Expand Down Expand Up @@ -330,11 +330,11 @@
.expect("Oh no I couldn't create the lock file");

// after
auto fileLock = iox::posix::FileLockBuilder().name("lockFileName")
.path("/Now/I/Can/Add/A/Path")
.permission(iox::perms::owner_all)
.create()
.expect("Oh no I couldn't create the lock file");
auto fileLock = iox::FileLockBuilder().name("lockFileName")
.path("/Now/I/Can/Add/A/Path")
.permission(iox::perms::owner_all)
.create()
.expect("Oh no I couldn't create the lock file");
```

10. `isValidFilePath` is removed use `isValidPathToFile` instead.
Expand Down Expand Up @@ -651,9 +651,9 @@
myMutex.lock();

// after
iox::optional<mutex> myMutex;
iox::posix::MutexBuilder()
.mutexType(iox::posix::MutexType::RECURSIVE)
iox::optional<iox::mutex> myMutex;
iox::MutexBuilder()
.mutexType(iox::MutexType::RECURSIVE)
.create(myMutex);
myMutex->lock();
```
Expand Down Expand Up @@ -1266,3 +1266,5 @@
// after
IOX_POSIX_CALL(open)("/hypnotoad");
```

57. `iox::posix::getSchedulerPriorityMinimum` and `iox::posix::getSchedulerPriorityMaximum` has become internal API
10 changes: 5 additions & 5 deletions iceoryx_dust/posix/ipc/include/iox/named_pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "iceoryx_hoofs/concurrent/lockfree_queue.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object.hpp"
#include "iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp"
#include "iceoryx_platform/semaphore.hpp"
#include "iox/builder.hpp"
#include "iox/duration.hpp"
Expand All @@ -30,6 +29,7 @@
#include "iox/posix_ipc_channel.hpp"
#include "iox/string.hpp"
#include "iox/uninitialized_array.hpp"
#include "iox/unnamed_semaphore.hpp"

#include <cstdint>

Expand Down Expand Up @@ -128,8 +128,8 @@ class NamedPipe
NamedPipeData& operator=(NamedPipeData&& rhs) = delete;
~NamedPipeData() = default;

posix::UnnamedSemaphore& sendSemaphore() noexcept;
posix::UnnamedSemaphore& receiveSemaphore() noexcept;
UnnamedSemaphore& sendSemaphore() noexcept;
UnnamedSemaphore& receiveSemaphore() noexcept;

expected<void, PosixIpcChannelError> initialize(const uint32_t maxMsgNumber) noexcept;

Expand All @@ -145,8 +145,8 @@ class NamedPipe
static constexpr units::Duration WAIT_FOR_INIT_SLEEP_TIME = units::Duration::fromMilliseconds(1);

std::atomic<uint64_t> initializationGuard{INVALID_DATA};
optional<posix::UnnamedSemaphore> m_sendSemaphore;
optional<posix::UnnamedSemaphore> m_receiveSemaphore;
optional<UnnamedSemaphore> m_sendSemaphore;
optional<UnnamedSemaphore> m_receiveSemaphore;
};

private:
Expand Down
3 changes: 0 additions & 3 deletions iceoryx_dust/posix/ipc/source/named_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@

namespace iox
{
using posix::SemaphoreWaitState;
using posix::SharedMemory;
using posix::SharedMemoryObject;
using posix::SharedMemoryObjectBuilder;
using posix::UnnamedSemaphore;
using posix::UnnamedSemaphoreBuilder;

/// NOLINTJUSTIFICATION see declaration in header
/// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays)
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_dust/posix/sync/include/iox/signal_watcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#define IOX_DUST_POSIX_WRAPPER_SIGNAL_WATCHER_HPP

#include "iceoryx_hoofs/posix_wrapper/signal_handler.hpp"
#include "iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp"
#include "iox/optional.hpp"
#include "iox/unnamed_semaphore.hpp"

#include <atomic>

Expand Down Expand Up @@ -68,7 +68,7 @@ class SignalWatcher
private:
friend void internalSignalHandler(int) noexcept;
mutable std::atomic<uint64_t> m_numberOfWaiters{0U};
mutable optional<posix::UnnamedSemaphore> m_semaphore;
mutable optional<UnnamedSemaphore> m_semaphore;

std::atomic_bool m_hasSignalOccurred{false};
posix::SignalGuard m_sigTermGuard;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_dust/posix/sync/source/signal_watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SignalWatcher::SignalWatcher() noexcept
, m_sigIntGuard(
registerSignalHandler(posix::Signal::INT, internalSignalHandler).expect("Unable to register Signal::INT"))
{
posix::UnnamedSemaphoreBuilder()
UnnamedSemaphoreBuilder()
.isInterProcessCapable(false)
.create(m_semaphore)

Expand Down
4 changes: 4 additions & 0 deletions iceoryx_hoofs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ cc_library(
"posix/design/source/*.cpp",
"posix/filesystem/source/*.cpp",
"posix/ipc/source/*.cpp",
"posix/sync/source/*.cpp",
"posix/time/source/*.cpp",
"posix/utility/source/*.cpp",
"posix/vocabulary/source/*.cpp",
"primitives/source/*.cpp",
"reporting/source/log/building_blocks/*.cpp",
Expand All @@ -72,7 +74,9 @@ cc_library(
"posix/design/include/",
"posix/filesystem/include/",
"posix/ipc/include/",
"posix/sync/include/",
"posix/time/include/",
"posix/utility/include/",
"posix/vocabulary/include/",
"primitives/include/",
"reporting/include/",
Expand Down
20 changes: 12 additions & 8 deletions iceoryx_hoofs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ iox_add_library(
${PROJECT_SOURCE_DIR}/posix/design/include
${PROJECT_SOURCE_DIR}/posix/ipc/include
${PROJECT_SOURCE_DIR}/posix/filesystem/include
${PROJECT_SOURCE_DIR}/posix/sync/include
${PROJECT_SOURCE_DIR}/posix/time/include
${PROJECT_SOURCE_DIR}/posix/utility/include
${PROJECT_SOURCE_DIR}/posix/vocabulary/include

${CMAKE_BINARY_DIR}/generated/iceoryx_hoofs/include
Expand All @@ -88,7 +90,9 @@ iox_add_library(
posix/design/include/
posix/ipc/include/
posix/filesystem/include/
posix/sync/include/
posix/time/include/
posix/utility/include/
posix/vocabulary/include/
FILES
design/source/functional_interface.cpp
Expand All @@ -103,18 +107,10 @@ iox_add_library(
source/cxx/requires.cpp
source/error_handling/error_handler.cpp
source/error_handling/error_handling.cpp
source/posix_wrapper/file_lock.cpp
source/posix_wrapper/mutex.cpp
source/posix_wrapper/named_semaphore.cpp
source/posix_wrapper/scheduler.cpp
source/posix_wrapper/semaphore_interface.cpp
source/posix_wrapper/shared_memory_object.cpp
source/posix_wrapper/shared_memory_object/memory_map.cpp
source/posix_wrapper/shared_memory_object/shared_memory.cpp
source/posix_wrapper/signal_handler.cpp
source/posix_wrapper/system_configuration.cpp
source/posix_wrapper/thread.cpp
source/posix_wrapper/unnamed_semaphore.cpp
source/error_reporting/custom/default/default_error_handler.cpp
time/source/duration.cpp
utility/source/unique_id.cpp
Expand All @@ -124,9 +120,17 @@ iox_add_library(
posix/design/source/file_management_interface.cpp
posix/ipc/source/unix_domain_socket.cpp
posix/filesystem/source/file.cpp
posix/filesystem/source/file_lock.cpp
posix/filesystem/source/posix_acl.cpp
posix/sync/source/mutex.cpp
posix/sync/source/named_semaphore.cpp
posix/sync/source/semaphore_interface.cpp
posix/sync/source/thread.cpp
posix/sync/source/unnamed_semaphore.cpp
posix/time/source/adaptive_wait.cpp
posix/time/source/deadline_timer.cpp
posix/utility/source/posix_scheduler.cpp
posix/utility/source/system_configuration.cpp
posix/vocabulary/source/file_name.cpp
posix/vocabulary/source/file_path.cpp
posix/vocabulary/source/group_name.cpp
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The module structure is a logical grouping. It is replicated for `concurrent` an
|`system_configuration` | i | Collection of free functions which acquire system information like the page-size. |
|`UniqueId` | i | Monotonic increasing IDs within a process. |
|`into` | i | |
|`Scheduler` | i | Supported schedulers and functions to get their priority range are contained here. |

### Primitives (primitives)

Expand Down Expand Up @@ -126,7 +127,6 @@ The module structure is a logical grouping. It is replicated for `concurrent` an
|`PeriodicTask` | i | Periodically executes a callable specified by the template parameter in a configurable time interval. |
|`smart_lock` | i | Creates arbitrary thread-safe constructs which then can be used like smart pointers. If some STL type should be thread safe use the smart_lock to create the thread safe version in one line. Based on some ideas presented in [Wrapping C++ Member Function Calls](https://stroustrup.com/wrapper.pdf) |
|`mutex` | i | Mutex interface, see [ManPage pthread_mutex_lock](https://man7.org/linux/man-pages/man3/pthread_mutex_lock.3p.html). |
|`Scheduler` | | Supported schedulers and functions to get their priority range are contained here. |
|`UnnamedSemaphore` | | Unamed semaphore interface, see [ManPage sem_overview](https://man7.org/linux/man-pages/man7/sem_overview.7.html) |
|`NamedSemaphore` | | Named semaphore interface, see [ManPage sem_overview](https://man7.org/linux/man-pages/man7/sem_overview.7.html) |
|`thread` | | Heap-less replacement for `std::thread`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#ifndef IOX_HOOFS_CONCURRENT_PERIODIC_TASK_HPP
#define IOX_HOOFS_CONCURRENT_PERIODIC_TASK_HPP

#include "iceoryx_hoofs/posix_wrapper/thread.hpp"
#include "iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp"
#include "iox/duration.hpp"
#include "iox/string.hpp"
#include "iox/thread.hpp"
#include "iox/unnamed_semaphore.hpp"

#include <thread>

Expand Down Expand Up @@ -74,7 +74,7 @@ class PeriodicTask
template <typename... Args>
// PeriodicTaskManualStart_t is a compile time constant to indicate that this constructor does not start the task
// NOLINTNEXTLINE(hicpp-named-parameter, readability-named-parameter)
PeriodicTask(const PeriodicTaskManualStart_t, const posix::ThreadName_t& taskName, Args&&... args) noexcept;
PeriodicTask(const PeriodicTaskManualStart_t, const ThreadName_t& taskName, Args&&... args) noexcept;

/// @brief Creates a periodic task by spawning a thread. The specified callable is executed immediately on creation
/// and then periodically after the interval duration.
Expand All @@ -89,7 +89,7 @@ class PeriodicTask
// NOLINTNEXTLINE(hicpp-named-parameter, readability-named-parameter)
PeriodicTask(const PeriodicTaskAutoStart_t,
const units::Duration interval,
const posix::ThreadName_t& taskName,
const ThreadName_t& taskName,
Args&&... args) noexcept;

/// @brief Stops and joins the thread spawned by the constructor.
Expand Down Expand Up @@ -123,9 +123,9 @@ class PeriodicTask

private:
T m_callable;
posix::ThreadName_t m_taskName;
ThreadName_t m_taskName;
units::Duration m_interval{units::Duration::fromMilliseconds(0U)};
optional<posix::UnnamedSemaphore> m_stop;
optional<UnnamedSemaphore> m_stop;
std::thread m_taskExecutor;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ template <typename T>
template <typename... Args>
// NOLINTNEXTLINE(hicpp-named-parameter, readability-named-parameter) justification in header
inline PeriodicTask<T>::PeriodicTask(const PeriodicTaskManualStart_t,
const posix::ThreadName_t& taskName,
const ThreadName_t& taskName,
Args&&... args) noexcept
: m_callable(std::forward<Args>(args)...)
, m_taskName(taskName)
{
posix::UnnamedSemaphoreBuilder().initialValue(0U).isInterProcessCapable(false).create(m_stop).expect(
UnnamedSemaphoreBuilder().initialValue(0U).isInterProcessCapable(false).create(m_stop).expect(
"Unable to create semaphore for periodic task");
}

Expand All @@ -41,7 +41,7 @@ template <typename... Args>
// NOLINTNEXTLINE(hicpp-named-parameter, readability-named-parameter) justification in header
inline PeriodicTask<T>::PeriodicTask(const PeriodicTaskAutoStart_t,
const units::Duration interval,
const posix::ThreadName_t& taskName,
const ThreadName_t& taskName,
Args&&... args) noexcept
: PeriodicTask(PeriodicTaskManualStart, taskName, std::forward<Args>(args)...)
{
Expand All @@ -60,7 +60,7 @@ inline void PeriodicTask<T>::start(const units::Duration interval) noexcept
stop();
m_interval = interval;
m_taskExecutor = std::thread(&PeriodicTask::run, this);
posix::setThreadName(m_taskExecutor.native_handle(), m_taskName);
setThreadName(m_taskExecutor.native_handle(), m_taskName);
}

template <typename T>
Expand All @@ -82,7 +82,7 @@ inline bool PeriodicTask<T>::isActive() const noexcept
template <typename T>
inline void PeriodicTask<T>::run() noexcept
{
posix::SemaphoreWaitState waitState = posix::SemaphoreWaitState::NO_TIMEOUT;
auto waitState = SemaphoreWaitState::NO_TIMEOUT;
do
{
m_callable();
Expand All @@ -93,7 +93,7 @@ inline void PeriodicTask<T>::run() noexcept
IOX_EXPECTS(!waitResult.has_error());

waitState = waitResult.value();
} while (waitState == posix::SemaphoreWaitState::TIMEOUT);
} while (waitState == SemaphoreWaitState::TIMEOUT);
}

} // namespace concurrent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2021 - 2022 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_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP
#define IOX_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP

#include "iox/detail/deprecation_marker.hpp"
#include "iox/file_lock.hpp"

IOX_DEPRECATED_HEADER_SINCE(3, "Please include 'iox/file_lock.hpp' instead.")

namespace iox
{
namespace posix
{
using FileLockError
IOX_DEPRECATED_SINCE(3, "Please use 'iox::FileLockError' from 'iox/file_lock.hpp' instead.") = FileLockError;
using FileLock IOX_DEPRECATED_SINCE(3, "Please use 'iox::FileLock' from 'iox/file_lock.hpp' instead.") = FileLock;
} // namespace posix
} // namespace iox

#endif // IOX_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP
Loading

0 comments on commit e0f686e

Please sign in to comment.