Skip to content

Commit 324ab7a

Browse files
authored
Fix CPPLint issues with select_op (#10072)
1 parent 1221412 commit 324ab7a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

paddle/fluid/operators/select_op.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15-
#include <boost/tokenizer.hpp>
1615
#include <memory>
17-
#include <thread>
16+
#include <thread> // NOLINT
1817
#include <vector>
1918
#include "paddle/fluid/framework/channel.h"
2019
#include "paddle/fluid/framework/executor.h"
2120
#include "paddle/fluid/framework/lod_tensor.h"
2221
#include "paddle/fluid/framework/op_registry.h"
2322
#include "paddle/fluid/operators/concurrency/channel_util.h"
2423

24+
#include <boost/tokenizer.hpp>
25+
2526
namespace paddle {
2627
namespace operators {
2728

@@ -254,8 +255,8 @@ class SelectOp : public framework::OperatorBase {
254255
auto selectCond = std::make_shared<std::condition_variable_any>();
255256

256257
std::recursive_mutex callbackMutex;
257-
pushThreadOnChannelQueues(scope, cases, selectCond, caseToExecute,
258-
completed, callbackMutex);
258+
pushThreadOnChannelQueues(scope, cases, selectCond, &caseToExecute,
259+
&completed, &callbackMutex);
259260

260261
// TODO(thuan): Atomically unlock all channels and sleep current thread
261262
unlockChannels(channels);
@@ -302,8 +303,8 @@ class SelectOp : public framework::OperatorBase {
302303
const framework::Scope *scope,
303304
std::vector<std::shared_ptr<SelectOpCase>> *cases,
304305
std::shared_ptr<std::condition_variable_any> rCond,
305-
std::atomic<int> &caseToExecute, std::atomic<bool> &completed,
306-
std::recursive_mutex &callbackMutex) const {
306+
std::atomic<int> *caseToExecute, std::atomic<bool> *completed,
307+
std::recursive_mutex *callbackMutex) const {
307308
std::vector<std::shared_ptr<SelectOpCase>>::iterator it = cases->begin();
308309
while (it != cases->end()) {
309310
std::shared_ptr<SelectOpCase> c = *it;
@@ -315,17 +316,17 @@ class SelectOp : public framework::OperatorBase {
315316
std::function<bool(framework::ChannelAction channelAction)> cb =
316317
[&caseToExecute, &completed, &callbackMutex,
317318
c](framework::ChannelAction channelAction) {
318-
std::lock_guard<std::recursive_mutex> lock{callbackMutex};
319+
std::lock_guard<std::recursive_mutex> lock{*callbackMutex};
319320

320321
bool canProcess = false;
321-
if (!completed) {
322+
if (!(*completed)) {
322323
// If the channel wasn't closed, we set the caseToExecute index
323324
// as this current case
324325
if (channelAction != framework::ChannelAction::CLOSE) {
325-
caseToExecute = c->caseIndex;
326+
*caseToExecute = c->caseIndex;
326327
}
327328
// This will allow our conditional variable to break out of wait
328-
completed = true;
329+
*completed = true;
329330
canProcess = true;
330331
}
331332

0 commit comments

Comments
 (0)