Skip to content

Commit e2cd786

Browse files
committed
[fix][test] Store receiveAsync callback in lvalue to clarify lifetime semantics
1 parent f826a13 commit e2cd786

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

tests/TypedMessageTest.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ TEST(TypedMessageTest, testReceive) {
6565
ASSERT_EQ(ResultOk, consumer.receive(msg, 3000, intDecoder));
6666
} else {
6767
Latch latch{1};
68-
consumer.receiveAsync<int>(
68+
std::function<void(Result result, const TypedMessage<int>&)> callback =
6969
[&latch, &msg, &msgMutex](Result result, const TypedMessage<int>& receivedMsg) {
7070
ASSERT_EQ(ResultOk, result);
7171
{
7272
std::lock_guard<std::mutex> lock{msgMutex};
7373
msg = receivedMsg;
7474
}
7575
latch.countdown();
76-
},
77-
intDecoder);
76+
};
77+
consumer.receiveAsync<int>(callback, intDecoder);
7878
ASSERT_TRUE(latch.wait(std::chrono::seconds(1)));
7979
}
8080

0 commit comments

Comments
 (0)