MCPcopy Create free account
hub / github.com/apache/brpc / TEST

Function TEST

test/cancelable_callback_unittest.cc:28–43  ·  view source on GitHub ↗

Cancel(). - Callback can be run multiple times. - After Cancel(), Run() completes but has no effect.

Source from the content-addressed store, hash-verified

26// - Callback can be run multiple times.
27// - After Cancel(), Run() completes but has no effect.
28TEST(CancelableCallbackTest, Cancel) {
29 int count = 0;
30 CancelableClosure cancelable(
31 butil::Bind(&Increment, butil::Unretained(&count)));
32
33 butil::Closure callback = cancelable.callback();
34 callback.Run();
35 EXPECT_EQ(1, count);
36
37 callback.Run();
38 EXPECT_EQ(2, count);
39
40 cancelable.Cancel();
41 callback.Run();
42 EXPECT_EQ(2, count);
43}
44
45// Cancel() called multiple times.
46// - Cancel() cancels all copies of the wrapped callback.

Callers

nothing calls this directly

Calls 7

HasOneRefMethod · 0.80
RunMethod · 0.45
CancelMethod · 0.45
is_nullMethod · 0.45
IsCancelledMethod · 0.45
getMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected