diff --git a/packages/camera/CMakeLists.txt b/packages/camera/CMakeLists.txt index 98fec16..21f053b 100644 --- a/packages/camera/CMakeLists.txt +++ b/packages/camera/CMakeLists.txt @@ -15,13 +15,13 @@ find_package(yaml_cpp_vendor REQUIRED) find_package(geometry_msgs REQUIRED) find_package(Boost REQUIRED) find_package(camera_srvs REQUIRED) +find_package(lock_free_queue REQUIRED) add_library(mvsdk SHARED IMPORTED) set_target_properties(mvsdk PROPERTIES IMPORTED_LOCATION "/lib/libMVSDK.so") -# add_library(queue_lib SHARED IMPORTED) -# set_target_properties(queue_lib PROPERTIES IMPORTED_LOCATION "/handy/install/lock_free_queue/lib/libqueue_lib.so") +add_library(queue_lib INTERFACE) add_executable(camera src/camera_main.cpp src/camera.cpp src/params.cpp src/camera_status.cpp) add_executable(calibration src/calibration_main.cpp src/calibration.cpp src/params.cpp) @@ -40,7 +40,8 @@ ament_target_dependencies( cv_bridge OpenCV sensor_msgs - yaml_cpp_vendor) + yaml_cpp_vendor + lock_free_queue) ament_target_dependencies( calibration @@ -57,8 +58,7 @@ ament_target_dependencies( Boost camera_srvs) -target_link_libraries(camera mvsdk) -# target_link_libraries(camera queue_lib) +target_link_libraries(camera mvsdk queue_lib) install(TARGETS camera calibration DESTINATION lib/${PROJECT_NAME}) diff --git a/packages/camera/include/camera.h b/packages/camera/include/camera.h index 3d7e5c0..a1572be 100644 --- a/packages/camera/include/camera.h +++ b/packages/camera/include/camera.h @@ -6,7 +6,7 @@ #include #include "CameraApi.h" -#include "lock_free_queue_impl.h" +#include "lock_free_queue.h" #include "params.h" #include diff --git a/packages/camera/package.xml b/packages/camera/package.xml index 69eb604..02ac16c 100644 --- a/packages/camera/package.xml +++ b/packages/camera/package.xml @@ -21,6 +21,7 @@ yaml_cpp_vendor Boost camera_srvs + lock_free_queue ament_lint_auto ament_lint_common diff --git a/packages/lock_free_queue/CMakeLists.txt b/packages/lock_free_queue/CMakeLists.txt index d8128ed..ed06841 100644 --- a/packages/lock_free_queue/CMakeLists.txt +++ b/packages/lock_free_queue/CMakeLists.txt @@ -5,14 +5,13 @@ find_package(ament_cmake_gtest REQUIRED) add_compile_options(-Wall -Wextra -Wpedantic -Wno-dev) -add_library(queue_lib SHARED src/lock_free_queue.cpp) -target_include_directories(queue_lib PUBLIC +add_library(queue_lib INTERFACE) +target_include_directories(queue_lib INTERFACE "$") -install(TARGETS queue_lib LIBRARY DESTINATION lib) - -ament_add_gtest(queue_test tests/src/test.cpp src/lock_free_queue.cpp) +ament_add_gtest(queue_test tests/src/test.cpp) target_include_directories(queue_test PUBLIC "$") +target_link_libraries(queue_test queue_lib) ament_package() diff --git a/packages/lock_free_queue/include/lock_free_queue_impl.h b/packages/lock_free_queue/include/lock_free_queue.h similarity index 100% rename from packages/lock_free_queue/include/lock_free_queue_impl.h rename to packages/lock_free_queue/include/lock_free_queue.h diff --git a/packages/lock_free_queue/include/lock_free_queue_decl.h b/packages/lock_free_queue/include/lock_free_queue_decl.h deleted file mode 100644 index 1f64aec..0000000 --- a/packages/lock_free_queue/include/lock_free_queue_decl.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include - -namespace handy { - -/* - Node consists of the value itself and index of the vector where it was added - this index is required to solve ABA problem -*/ -template -struct Node { - T value; - // generation is changed on each assignment and then used to determine - // whether this Node was changed by different thread or not - std::atomic generation{0}; -}; - -template -class LockFreeQueue { - public: - explicit LockFreeQueue(int size); - - LockFreeQueue(LockFreeQueue&& other) = delete; - LockFreeQueue(const LockFreeQueue& other) = delete; - - bool push(const T& value); - bool pop(T& data); - - private: - std::vector> data_; - std::atomic head_ = 0; - std::atomic tail_ = 0; -}; -} // namespace handy diff --git a/packages/lock_free_queue/src/lock_free_queue.cpp b/packages/lock_free_queue/src/lock_free_queue.cpp deleted file mode 100644 index abd9454..0000000 --- a/packages/lock_free_queue/src/lock_free_queue.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "lock_free_queue_impl.h" diff --git a/packages/lock_free_queue/tests/src/test.cpp b/packages/lock_free_queue/tests/src/test.cpp index 5ea8d31..357042f 100644 --- a/packages/lock_free_queue/tests/src/test.cpp +++ b/packages/lock_free_queue/tests/src/test.cpp @@ -1,4 +1,4 @@ -#include "lock_free_queue_impl.h" +#include "lock_free_queue.h" #include