Skip to content

Commit

Permalink
Merge pull request PointCloudLibrary#3094 from SergioRAgostinho/thread
Browse files Browse the repository at this point in the history
 Remove last traces of Boost Thread
  • Loading branch information
SergioRAgostinho authored May 20, 2019
2 parents 87b5ff6 + 0136e76 commit 0a5baca
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 52 deletions.
4 changes: 2 additions & 2 deletions cmake/pcl_find_boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ endif()

# Required boost modules
if(WITH_OPENNI2)
set(BOOST_REQUIRED_MODULES filesystem thread date_time iostreams chrono system)
set(BOOST_REQUIRED_MODULES filesystem date_time iostreams chrono system)
find_package(Boost 1.55.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES})
else()
set(BOOST_REQUIRED_MODULES filesystem thread date_time iostreams system)
set(BOOST_REQUIRED_MODULES filesystem date_time iostreams system)
find_package(Boost 1.55.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES})
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/pcl_pclconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ foreach(_ss ${PCL_SUBSYSTEMS_MODULES})
endforeach()

#Boost modules
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "system filesystem thread date_time iostreams")
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "system filesystem date_time iostreams")
if(Boost_SERIALIZATION_FOUND)
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "${PCLCONFIG_AVAILABLE_BOOST_MODULES} serialization")
endif()
Expand Down
1 change: 0 additions & 1 deletion common/include/pcl/common/time_trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <pcl/pcl_macros.h>
#ifndef Q_MOC_RUN
#include <boost/function.hpp>
#include <boost/thread.hpp>
#include <boost/signals2.hpp>
#endif

Expand Down
6 changes: 0 additions & 6 deletions doc/tutorials/content/building_pcl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,6 @@ then a sample value is given for reference.
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
| Boost_SYSTEM_LIBRARY_RELEASE | full path to boost_system.[so,lib,a] (release version) | /usr/local/lib/libboost_system.so |
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
| Boost_THREAD_LIBRARY | full path to boost_thread.[so,lib,a] | /usr/local/lib/libboost_thread.so |
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
| Boost_THREAD_LIBRARY_DEBUG | full path to boost_thread.[so,lib,a] (debug version) | /usr/local/lib/libboost_thread-gd.so |
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
| Boost_THREAD_LIBRARY_RELEASE | full path to boost_thread.[so,lib,a] (release version) | /usr/local/lib/libboost_thread.so |
+----------------------------------+---------------------------------------------------------------+------------------------------------------+


* CMinpack
Expand Down
3 changes: 1 addition & 2 deletions doc/tutorials/content/compiling_pcl_dependencies_windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ like::
then fill the **BUILD_PROJECTS** CMake entry (which is set to `ALL` by default) with a semicolon-seperated
list of boost modules::
BUILD_PROJECTS : system;filesystem;date_time;thread;iostreams;tr1;serialization
BUILD_PROJECTS : system;filesystem;date_time;iostreams;tr1;serialization
Also, uncheck the **ENABLE_STATIC_RUNTIME** checkbox. Then, click "Configure" again. If you get some
errors related to Python, then uncheck **WITH_PYTHON** checkbox, and click "Configure" again.
Expand All @@ -144,7 +144,6 @@ like::
Reading boost project directories (per BUILD_PROJECTS)
+ date_time
+ thread
+ serialization
+ system
+ filesystem
Expand Down
16 changes: 8 additions & 8 deletions gpu/kinfu/tools/kinfu_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ struct KinFuApp
void source_cb1_device(const boost::shared_ptr<openni_wrapper::DepthImage>& depth_wrapper)
{
{
boost::mutex::scoped_try_lock lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock (data_ready_mutex_, std::try_to_lock);
if (exit_ || !lock)
return;

Expand All @@ -849,7 +849,7 @@ struct KinFuApp
void source_cb2_device(const boost::shared_ptr<openni_wrapper::Image>& image_wrapper, const boost::shared_ptr<openni_wrapper::DepthImage>& depth_wrapper, float)
{
{
boost::mutex::scoped_try_lock lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock (data_ready_mutex_, std::try_to_lock);
if (exit_ || !lock)
return;

Expand All @@ -876,7 +876,7 @@ struct KinFuApp
void source_cb1_oni(const boost::shared_ptr<openni_wrapper::DepthImage>& depth_wrapper)
{
{
boost::mutex::scoped_lock lock(data_ready_mutex_);
std::lock_guard<std::mutex> lock(data_ready_mutex_);
if (exit_)
return;

Expand All @@ -894,7 +894,7 @@ struct KinFuApp
void source_cb2_oni(const boost::shared_ptr<openni_wrapper::Image>& image_wrapper, const boost::shared_ptr<openni_wrapper::DepthImage>& depth_wrapper, float)
{
{
boost::mutex::scoped_lock lock(data_ready_mutex_);
std::lock_guard<std::mutex> lock(data_ready_mutex_);
if (exit_)
return;

Expand All @@ -921,7 +921,7 @@ struct KinFuApp
source_cb3 (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr & DC3)
{
{
boost::mutex::scoped_try_lock lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock (data_ready_mutex_, std::try_to_lock);
if (exit_ || !lock)
return;
int width = DC3->width;
Expand Down Expand Up @@ -981,7 +981,7 @@ struct KinFuApp
boost::signals2::connection c = pcd_source_? capture_.registerCallback (func3) : need_colors ? capture_.registerCallback (func1) : capture_.registerCallback (func2);

{
boost::unique_lock<boost::mutex> lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock(data_ready_mutex_);

if (!triggered_capture)
capture_.start (); // Start stream
Expand Down Expand Up @@ -1097,8 +1097,8 @@ struct KinFuApp

Evaluation::Ptr evaluation_ptr_;

boost::mutex data_ready_mutex_;
boost::condition_variable data_ready_cond_;
std::mutex data_ready_mutex_;
std::condition_variable data_ready_cond_;

std::vector<KinfuTracker::PixelRGB> source_image_data_;
std::vector<unsigned short> source_depth_data_;
Expand Down
12 changes: 6 additions & 6 deletions gpu/kinfu_large_scale/tools/kinfuLS_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ struct KinFuLSApp
void source_cb1(const boost::shared_ptr<openni_wrapper::DepthImage>& depth_wrapper)
{
{
boost::mutex::scoped_try_lock lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock (data_ready_mutex_, std::try_to_lock);
if (exit_ || !lock)
return;

Expand All @@ -908,7 +908,7 @@ struct KinFuLSApp
void source_cb2(const boost::shared_ptr<openni_wrapper::Image>& image_wrapper, const boost::shared_ptr<openni_wrapper::DepthImage>& depth_wrapper, float)
{
{
boost::mutex::scoped_try_lock lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock (data_ready_mutex_, std::try_to_lock);

if (exit_ || !lock)
{
Expand Down Expand Up @@ -939,7 +939,7 @@ struct KinFuLSApp
{
{
//std::cout << "Giving colors1\n";
boost::mutex::scoped_try_lock lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock (data_ready_mutex_, std::try_to_lock);
//std::cout << lock << std::endl; //causes compile errors
if (exit_ || !lock)
return;
Expand Down Expand Up @@ -994,7 +994,7 @@ struct KinFuLSApp
boost::signals2::connection c = pcd_source_? capture_.registerCallback (func3) : need_colors ? capture_.registerCallback (func1) : capture_.registerCallback (func2);

{
boost::unique_lock<boost::mutex> lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock(data_ready_mutex_);

if (!triggered_capture)
capture_.start ();
Expand Down Expand Up @@ -1109,8 +1109,8 @@ struct KinFuLSApp

Evaluation::Ptr evaluation_ptr_;

boost::mutex data_ready_mutex_;
boost::condition_variable data_ready_cond_;
std::mutex data_ready_mutex_;
std::condition_variable data_ready_cond_;

std::vector<pcl::gpu::kinfuLS::PixelRGB> source_image_data_;
std::vector<unsigned short> source_depth_data_;
Expand Down
43 changes: 22 additions & 21 deletions gpu/kinfu_large_scale/tools/record_maps_rgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,23 @@
* Author: Raphael Favier, Technical University Eindhoven, (r.mysurname < aT > tue.nl)
*/

#include <csignal>
#include <ctime>
#include <thread>

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/openni_grabber.h>
#include <boost/thread/condition.hpp>
#include <boost/circular_buffer.hpp>
#include <pcl/io/pcd_io.h>
#include <pcl/common/time.h> //fps calculations

#include <pcl/gpu/containers/kernel_containers.h>
#include <pcl/io/png_io.h>
#include <pcl/console/print.h>

#include <boost/circular_buffer.hpp>

#include <condition_variable>
#include <csignal>
#include <ctime>
#include <mutex>
#include <thread>

using namespace std::chrono_literals;

#define FPS_CALC(_WHAT_) \
Expand All @@ -66,7 +67,7 @@ do \
}while(false)

bool is_done = false;
boost::mutex io_mutex;
std::mutex io_mutex;

const int BUFFER_SIZE = 1000;
static int counter = 1;
Expand Down Expand Up @@ -98,21 +99,21 @@ class MapsBuffer
inline bool
isFull ()
{
boost::mutex::scoped_lock buff_lock (bmutex_);
std::lock_guard<std::mutex> buff_lock (bmutex_);
return (buffer_.full ());
}

inline bool
isEmpty ()
{
boost::mutex::scoped_lock buff_lock (bmutex_);
std::lock_guard<std::mutex> buff_lock (bmutex_);
return (buffer_.empty ());
}

inline int
getSize ()
{
boost::mutex::scoped_lock buff_lock (bmutex_);
std::lock_guard<std::mutex> buff_lock (bmutex_);
return (int (buffer_.size ()));
}

Expand All @@ -125,16 +126,16 @@ class MapsBuffer
inline void
setCapacity (int buff_size)
{
boost::mutex::scoped_lock buff_lock (bmutex_);
std::lock_guard<std::mutex> buff_lock (bmutex_);
buffer_.set_capacity (buff_size);
}

private:
MapsBuffer (const MapsBuffer&) = delete; // Disabled copy constructor
MapsBuffer& operator =(const MapsBuffer&) = delete; // Disabled assignment operator

boost::mutex bmutex_;
boost::condition_variable buff_empty_;
std::mutex bmutex_;
std::condition_variable buff_empty_;
boost::circular_buffer<boost::shared_ptr<const MapsRgb> > buffer_;

};
Expand All @@ -146,7 +147,7 @@ MapsBuffer::pushBack(boost::shared_ptr<const MapsRgb> maps_rgb )
{
bool retVal = false;
{
boost::mutex::scoped_lock buff_lock (bmutex_);
std::lock_guard<std::mutex> buff_lock (bmutex_);
if (!buffer_.full ())
retVal = true;
buffer_.push_back (maps_rgb);
Expand All @@ -162,13 +163,13 @@ MapsBuffer::getFront(bool print)
{
boost::shared_ptr< const MapsBuffer::MapsRgb > depth_rgb;
{
boost::mutex::scoped_lock buff_lock (bmutex_);
std::lock_guard<std::mutex> buff_lock (bmutex_);
while (buffer_.empty ())
{
if (is_done)
break;
{
boost::mutex::scoped_lock io_lock (io_mutex);
std::lock_guard<std::mutex> io_lock (io_mutex);
//std::cout << "No data in buffer_ yet or buffer is empty." << std::endl;
}
buff_empty_.wait (buff_lock);
Expand Down Expand Up @@ -242,7 +243,7 @@ grabberMapsCallBack(const boost::shared_ptr<openni_wrapper::Image>& image_wrappe
if (!buff.pushBack (ptr))
{
{
boost::mutex::scoped_lock io_lock(io_mutex);
std::lock_guard<std::mutex> io_lock(io_mutex);
PCL_WARN ("Warning! Buffer was full, overwriting data\n");
}
}
Expand Down Expand Up @@ -287,7 +288,7 @@ receiveAndProcess ()
}

{
boost::mutex::scoped_lock io_lock (io_mutex);
std::lock_guard<std::mutex> io_lock (io_mutex);
PCL_INFO ("Writing remaining %d maps in the buffer to disk...\n", buff.getSize ());
}
while (!buff.isEmpty ())
Expand All @@ -300,7 +301,7 @@ receiveAndProcess ()
void
ctrlC (int)
{
boost::mutex::scoped_lock io_lock (io_mutex);
std::lock_guard<std::mutex> io_lock (io_mutex);
std::cout << std::endl;
PCL_WARN ("Ctrl-C detected, exit condition set to true\n");
is_done = true;
Expand Down Expand Up @@ -331,7 +332,7 @@ main (int argc, char** argv)
signal (SIGINT, ctrlC);
producer.join ();
{
boost::mutex::scoped_lock io_lock (io_mutex);
std::lock_guard<std::mutex> io_lock (io_mutex);
PCL_WARN ("Producer done\n");
}
consumer.join ();
Expand Down
10 changes: 5 additions & 5 deletions gpu/people/tools/people_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class PeoplePCDApp
void source_cb1(const boost::shared_ptr<const PointCloud<PointXYZRGBA> >& cloud)
{
{
boost::mutex::scoped_lock lock(data_ready_mutex_);
std::lock_guard<std::mutex> lock(data_ready_mutex_);
if (exit_)
return;

Expand All @@ -226,7 +226,7 @@ class PeoplePCDApp
void source_cb2(const boost::shared_ptr<openni_wrapper::Image>& image_wrapper, const boost::shared_ptr<openni_wrapper::DepthImage>& depth_wrapper, float)
{
{
boost::mutex::scoped_try_lock lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock (data_ready_mutex_, std::try_to_lock);

if (exit_ || !lock)
return;
Expand Down Expand Up @@ -286,7 +286,7 @@ class PeoplePCDApp
boost::signals2::connection c = cloud_cb_ ? capture_.registerCallback (func1) : capture_.registerCallback (func2);

{
boost::unique_lock<boost::mutex> lock(data_ready_mutex_);
std::unique_lock<std::mutex> lock(data_ready_mutex_);

try
{
Expand Down Expand Up @@ -319,8 +319,8 @@ class PeoplePCDApp
c.disconnect();
}

boost::mutex data_ready_mutex_;
boost::condition_variable data_ready_cond_;
std::mutex data_ready_mutex_;
std::condition_variable data_ready_cond_;

pcl::Grabber& capture_;

Expand Down

0 comments on commit 0a5baca

Please sign in to comment.