Skip to content

Commit

Permalink
Remove fixed guard conditions
Browse files Browse the repository at this point in the history
* remove fixed guard conditions
  • Loading branch information
jacquelinekay committed Apr 1, 2016
1 parent 416831c commit 8e4586f
Showing 1 changed file with 2 additions and 51 deletions.
53 changes: 2 additions & 51 deletions rmw_fastrtps_cpp/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ extern "C"
}

rmw_waitset_t *
rmw_create_waitset(rmw_guard_conditions_t * fixed_guard_conditions, size_t max_conditions)
rmw_create_waitset(size_t max_conditions)
{
rmw_waitset_t * waitset = rmw_waitset_allocate();
GuardCondition * rtps_guard_cond = nullptr;
Expand All @@ -895,25 +895,6 @@ extern "C"
goto fail;
}

waitset->fixed_guard_conditions = fixed_guard_conditions;
if (fixed_guard_conditions) {
if (!fixed_guard_conditions->guard_conditions) {
RMW_SET_ERROR_MSG("Received invalid guard condition array");
goto fail;
}
// Attach the fixed guard conditions to the waitset (and detach them in destroy)
for (size_t i = 0; i < fixed_guard_conditions->guard_condition_count; ++i) {
void * guard_cond = fixed_guard_conditions->guard_conditions[i];
if (!guard_cond) {
RMW_SET_ERROR_MSG("Received invalid guard condition");
goto fail;
}
rtps_guard_cond = static_cast<GuardCondition *>(guard_cond);
rtps_guard_cond->attachCondition(
&waitset_info->condition_mutex, &waitset_info->condition);
}
}

return waitset;

fail:
Expand Down Expand Up @@ -952,25 +933,6 @@ extern "C"
return RMW_RET_ERROR;
}

rmw_guard_conditions_t * fixed_guard_conditions = waitset->fixed_guard_conditions;
if (fixed_guard_conditions && fixed_guard_conditions->guard_conditions) {
// Attach the fixed guard conditions to the waitset (and detach them in destroy)
std::unique_lock<std::mutex> lock(*conditionMutex);
for (size_t i = 0; i < fixed_guard_conditions->guard_condition_count; ++i) {
void * guard_cond = fixed_guard_conditions->guard_conditions[i];
if (!guard_cond) {
continue;
}
GuardCondition * rtps_guard_cond = static_cast<GuardCondition *>(guard_cond);
if (!rtps_guard_cond) {
continue;
}
lock.unlock();
rtps_guard_cond->dettachCondition();
lock.lock();
}
}

if (waitset) {
if (waitset->data) {
if (waitset_info) {
Expand Down Expand Up @@ -1641,7 +1603,6 @@ extern "C"
guard_condition->attachCondition(conditionMutex, conditionVariable);
}
}
rmw_guard_conditions_t * fixed_guard_conditions = waitset->fixed_guard_conditions;

std::unique_lock<std::mutex> lock(*conditionMutex);

Expand Down Expand Up @@ -1684,15 +1645,6 @@ extern "C"
hasToWait = false;
}
}
if (fixed_guard_conditions) {
for (unsigned long i = 0; hasToWait && i < fixed_guard_conditions->guard_condition_count; ++i)
{
void *data = fixed_guard_conditions->guard_conditions[i];
GuardCondition *guard_condition = (GuardCondition*)data;
if(guard_condition->getHasTriggered())
hasToWait = false;
}
}

if(hasToWait)
{
Expand Down Expand Up @@ -1751,8 +1703,7 @@ extern "C"
{
void *data = guard_conditions->guard_conditions[i];
GuardCondition *guard_condition = (GuardCondition*)data;
if(!guard_condition->getHasTriggered())
{
if (!guard_condition->getHasTriggered()) {
guard_conditions->guard_conditions[i] = 0;
}
lock.unlock();
Expand Down

0 comments on commit 8e4586f

Please sign in to comment.