Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
8d5f8f9c
Commit
8d5f8f9c
authored
Dec 05, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and test DynamicCapability tail calls.
parent
97687a67
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
4 deletions
+71
-4
capability-test.c++
c++/src/capnp/capability-test.c++
+68
-4
dynamic.h
c++/src/capnp/dynamic.h
+3
-0
No files found.
c++/src/capnp/capability-test.c++
View file @
8d5f8f9c
...
...
@@ -527,7 +527,7 @@ TEST(Capability, DynamicServerInheritance) {
class
TestPipelineDynamicImpl
final
:
public
DynamicCapability
::
Server
{
public
:
TestPipelineDynamicImpl
(
int
&
callCount
)
:
DynamicCapability
::
Server
(
Schema
::
from
<
test
::
Test
Extends
>
()),
:
DynamicCapability
::
Server
(
Schema
::
from
<
test
::
Test
Pipeline
>
()),
callCount
(
callCount
)
{}
int
&
callCount
;
...
...
@@ -559,8 +559,8 @@ public:
// Too lazy to write a whole separate test for each of these cases... so just make
// sure they both compile here, and only actually test the latter.
box
.
set
(
"
outC
ap"
,
kj
::
heap
<
TestExtendsDynamicImpl
>
(
callCount
));
box
.
set
(
"
outC
ap"
,
kj
::
heap
<
TestExtendsImpl
>
(
callCount
));
box
.
set
(
"
c
ap"
,
kj
::
heap
<
TestExtendsDynamicImpl
>
(
callCount
));
box
.
set
(
"
c
ap"
,
kj
::
heap
<
TestExtendsImpl
>
(
callCount
));
});
}
else
{
KJ_FAIL_ASSERT
(
"Method not implemented"
,
methodName
);
...
...
@@ -574,7 +574,9 @@ TEST(Capability, DynamicServerPipelining) {
int
callCount
=
0
;
int
chainedCallCount
=
0
;
test
::
TestPipeline
::
Client
client
(
kj
::
heap
<
TestPipelineImpl
>
(
callCount
));
test
::
TestPipeline
::
Client
client
=
DynamicCapability
::
Client
(
kj
::
heap
<
TestPipelineDynamicImpl
>
(
callCount
))
.
castAs
<
test
::
TestPipeline
>
();
auto
request
=
client
.
getCapRequest
();
request
.
setN
(
234
);
...
...
@@ -604,6 +606,68 @@ TEST(Capability, DynamicServerPipelining) {
EXPECT_EQ
(
1
,
chainedCallCount
);
}
class
TestTailCallerDynamicImpl
final
:
public
DynamicCapability
::
Server
{
public
:
TestTailCallerDynamicImpl
(
int
&
callCount
)
:
DynamicCapability
::
Server
(
Schema
::
from
<
test
::
TestTailCaller
>
()),
callCount
(
callCount
)
{}
int
&
callCount
;
kj
::
Promise
<
void
>
call
(
InterfaceSchema
::
Method
method
,
CallContext
<
DynamicStruct
,
DynamicStruct
>
context
)
{
auto
methodName
=
method
.
getProto
().
getName
();
if
(
methodName
==
"foo"
)
{
++
callCount
;
auto
params
=
context
.
getParams
();
auto
tailRequest
=
params
.
get
(
"callee"
).
as
<
DynamicCapability
>
().
newRequest
(
"foo"
);
tailRequest
.
set
(
"i"
,
params
.
get
(
"i"
));
tailRequest
.
set
(
"t"
,
"from TestTailCaller"
);
context
.
releaseParams
();
return
context
.
tailCall
(
kj
::
mv
(
tailRequest
));
}
else
{
KJ_FAIL_ASSERT
(
"Method not implemented"
,
methodName
);
}
}
};
TEST
(
Capability
,
DynamicServerTailCall
)
{
kj
::
EventLoop
loop
;
kj
::
WaitScope
waitScope
(
loop
);
int
calleeCallCount
=
0
;
int
callerCallCount
=
0
;
test
::
TestTailCallee
::
Client
callee
(
kj
::
heap
<
TestTailCalleeImpl
>
(
calleeCallCount
));
test
::
TestTailCaller
::
Client
caller
=
DynamicCapability
::
Client
(
kj
::
heap
<
TestTailCallerDynamicImpl
>
(
callerCallCount
))
.
castAs
<
test
::
TestTailCaller
>
();
auto
request
=
caller
.
fooRequest
();
request
.
setI
(
456
);
request
.
setCallee
(
callee
);
auto
promise
=
request
.
send
();
auto
dependentCall0
=
promise
.
getC
().
getCallSequenceRequest
().
send
();
auto
response
=
promise
.
wait
(
waitScope
);
EXPECT_EQ
(
456
,
response
.
getI
());
EXPECT_EQ
(
456
,
response
.
getI
());
auto
dependentCall1
=
promise
.
getC
().
getCallSequenceRequest
().
send
();
auto
dependentCall2
=
response
.
getC
().
getCallSequenceRequest
().
send
();
EXPECT_EQ
(
0
,
dependentCall0
.
wait
(
waitScope
).
getN
());
EXPECT_EQ
(
1
,
dependentCall1
.
wait
(
waitScope
).
getN
());
EXPECT_EQ
(
2
,
dependentCall2
.
wait
(
waitScope
).
getN
());
EXPECT_EQ
(
1
,
calleeCallCount
);
EXPECT_EQ
(
1
,
callerCallCount
);
}
// =======================================================================================
void
verifyClient
(
test
::
TestInterface
::
Client
client
,
const
int
&
callCount
,
...
...
c++/src/capnp/dynamic.h
View file @
8d5f8f9c
...
...
@@ -515,6 +515,9 @@ private:
friend
class
Capability
::
Client
;
friend
struct
DynamicCapability
;
template
<
typename
,
typename
>
friend
class
CallContext
;
friend
class
RequestHook
;
};
template
<>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment