implement shared lock in query
This commit is contained in:
parent
51d32bb8d3
commit
0d1149310c
@ -104,32 +104,40 @@ void OSRM::RunQuery(RouteParameters & route_parameters, http::Reply & reply) {
|
|||||||
if(plugin_map.end() != iter) {
|
if(plugin_map.end() != iter) {
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
if( use_shared_memory ) {
|
if( use_shared_memory ) {
|
||||||
//TODO lock update pending
|
// lock update pending
|
||||||
|
|
||||||
//TODO lock query
|
|
||||||
|
|
||||||
//TODO unlock update pending
|
|
||||||
|
|
||||||
//TODO ++query_count
|
|
||||||
|
|
||||||
//TODO unlock query
|
|
||||||
|
|
||||||
//wait until we get the mutex and free it immediately
|
|
||||||
//TODO: increment semaphore of querying processes
|
|
||||||
boost::interprocess::scoped_lock<
|
boost::interprocess::scoped_lock<
|
||||||
boost::interprocess::interprocess_mutex
|
boost::interprocess::named_mutex
|
||||||
> lock(barrier->update_mutex);
|
> pending_lock(barrier->pending_update_mutex);
|
||||||
|
|
||||||
|
// lock query
|
||||||
|
boost::interprocess::scoped_lock<
|
||||||
|
boost::interprocess::named_mutex
|
||||||
|
> query_lock(barrier->query_mutex);
|
||||||
|
|
||||||
|
// unlock update pending
|
||||||
|
pending_lock.unlock();
|
||||||
|
|
||||||
|
// increment query count
|
||||||
|
++(barrier->number_of_queries);
|
||||||
}
|
}
|
||||||
iter->second->HandleRequest(route_parameters, reply );
|
iter->second->HandleRequest(route_parameters, reply );
|
||||||
if( use_shared_memory ) {
|
if( use_shared_memory ) {
|
||||||
//TODO unlock update pending
|
// lock query
|
||||||
//TODO --query_count
|
boost::interprocess::scoped_lock<
|
||||||
//if (0 == query_count) {
|
boost::interprocess::named_mutex
|
||||||
//TODO notify.all query_count 0
|
> query_lock(barrier->query_mutex);
|
||||||
//}
|
|
||||||
//TODO unlock query
|
|
||||||
|
|
||||||
|
// decrement query count
|
||||||
|
--(barrier->number_of_queries);
|
||||||
|
BOOST_ASSERT_MSG(
|
||||||
|
0 <= barrier->number_of_queries,
|
||||||
|
"invalid number of queries"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (0 == barrier->number_of_queries) {
|
||||||
|
// notify all processes that were waiting for this condition
|
||||||
|
barrier->no_running_queries_condition.notify_all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reply = http::Reply::stockReply(http::Reply::badRequest);
|
reply = http::Reply::stockReply(http::Reply::badRequest);
|
||||||
|
Loading…
Reference in New Issue
Block a user