2015-01-27 06:35:29 -05:00
|
|
|
#ifndef SHARED_BARRIERS_HPP
|
|
|
|
#define SHARED_BARRIERS_HPP
|
2011-01-09 16:42:27 -05:00
|
|
|
|
2016-12-25 19:00:37 -05:00
|
|
|
#include <boost/interprocess/sync/named_condition.hpp>
|
|
|
|
#include <boost/interprocess/sync/named_mutex.hpp>
|
2011-01-09 16:42:27 -05:00
|
|
|
|
2017-01-05 17:38:48 -05:00
|
|
|
#include "util/retry_lock.hpp"
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
2016-01-07 13:19:55 -05:00
|
|
|
namespace storage
|
2016-01-05 10:51:13 -05:00
|
|
|
{
|
2016-10-07 19:52:47 -04:00
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
struct SharedBarriers
|
2014-05-07 10:50:48 -04:00
|
|
|
{
|
2013-12-13 17:26:57 -05:00
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
SharedBarriers()
|
2017-01-05 17:38:48 -05:00
|
|
|
: region_mutex(boost::interprocess::open_or_create, "osrm-region"),
|
|
|
|
region_condition(boost::interprocess::open_or_create, "osrm-region-cv")
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-25 19:00:37 -05:00
|
|
|
static void remove()
|
2016-10-12 15:26:59 -04:00
|
|
|
{
|
2016-12-25 19:00:37 -05:00
|
|
|
boost::interprocess::named_mutex::remove("osrm-region");
|
|
|
|
boost::interprocess::named_condition::remove("osrm-region-cv");
|
2016-10-12 15:26:59 -04:00
|
|
|
}
|
|
|
|
|
2017-01-05 17:38:48 -05:00
|
|
|
static RetryLock getLockWithRetry(int timeout_seconds)
|
|
|
|
{
|
|
|
|
return RetryLock(timeout_seconds, "osrm-region");
|
|
|
|
}
|
|
|
|
|
2016-12-25 19:00:37 -05:00
|
|
|
boost::interprocess::named_mutex region_mutex;
|
|
|
|
boost::interprocess::named_condition region_condition;
|
2011-01-09 16:42:27 -05:00
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
#endif // SHARED_BARRIERS_HPP
|