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
e22e5641
Commit
e22e5641
authored
Dec 29, 2014
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix joinPromises for Promise<void>.
parent
68ad3220
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
0 deletions
+41
-0
async-inl.h
c++/src/kj/async-inl.h
+24
-0
async-prelude.h
c++/src/kj/async-prelude.h
+2
-0
async-test.c++
c++/src/kj/async-test.c++
+14
-0
async.h
c++/src/kj/async.h
+1
-0
No files found.
c++/src/kj/async-inl.h
View file @
e22e5641
...
...
@@ -547,6 +547,24 @@ private:
Array
<
ExceptionOr
<
T
>>
resultParts
;
};
template
<>
class
ArrayJoinPromiseNode
<
void
>
final
:
public
ArrayJoinPromiseNodeBase
{
public
:
ArrayJoinPromiseNode
(
Array
<
Own
<
PromiseNode
>>
promises
,
Array
<
ExceptionOr
<
_
::
Void
>>
resultParts
)
:
ArrayJoinPromiseNodeBase
(
kj
::
mv
(
promises
),
resultParts
.
begin
(),
sizeof
(
ExceptionOr
<
_
::
Void
>
)),
resultParts
(
kj
::
mv
(
resultParts
))
{}
protected
:
void
getNoError
(
ExceptionOrValue
&
output
)
noexcept
override
{
output
.
as
<
_
::
Void
>
()
=
_
::
Void
();
}
private
:
Array
<
ExceptionOr
<
_
::
Void
>>
resultParts
;
};
// -------------------------------------------------------------------
class
EagerPromiseNodeBase
:
public
PromiseNode
,
protected
Event
{
...
...
@@ -758,6 +776,12 @@ Promise<Array<T>> joinPromises(Array<Promise<T>>&& promises) {
heapArray
<
_
::
ExceptionOr
<
T
>>
(
promises
.
size
())));
}
inline
Promise
<
void
>
joinPromises
(
Array
<
Promise
<
void
>>&&
promises
)
{
return
Promise
<
void
>
(
false
,
kj
::
heap
<
_
::
ArrayJoinPromiseNode
<
void
>>
(
KJ_MAP
(
p
,
promises
)
{
return
kj
::
mv
(
p
.
node
);
},
heapArray
<
_
::
ExceptionOr
<
_
::
Void
>>
(
promises
.
size
())));
}
// =======================================================================================
namespace
_
{
// private
...
...
c++/src/kj/async-prelude.h
View file @
e22e5641
...
...
@@ -40,6 +40,7 @@ class WaitScope;
template
<
typename
T
>
Promise
<
Array
<
T
>>
joinPromises
(
Array
<
Promise
<
T
>>&&
promises
);
Promise
<
void
>
joinPromises
(
Array
<
Promise
<
void
>>&&
promises
);
namespace
_
{
// private
...
...
@@ -181,6 +182,7 @@ private:
friend
class
TaskSetImpl
;
template
<
typename
U
>
friend
Promise
<
Array
<
U
>>
kj
::
joinPromises
(
Array
<
Promise
<
U
>>&&
promises
);
friend
Promise
<
void
>
kj
::
joinPromises
(
Array
<
Promise
<
void
>>&&
promises
);
};
void
detach
(
kj
::
Promise
<
void
>&&
promise
);
...
...
c++/src/kj/async-test.c++
View file @
e22e5641
...
...
@@ -531,6 +531,20 @@ TEST(Async, ArrayJoin) {
EXPECT_EQ
(
789
,
result
[
2
]);
}
TEST
(
Async
,
ArrayJoinVoid
)
{
EventLoop
loop
;
WaitScope
waitScope
(
loop
);
auto
builder
=
heapArrayBuilder
<
Promise
<
void
>>
(
3
);
builder
.
add
(
READY_NOW
);
builder
.
add
(
READY_NOW
);
builder
.
add
(
READY_NOW
);
Promise
<
void
>
promise
=
joinPromises
(
builder
.
finish
());
promise
.
wait
(
waitScope
);
}
class
ErrorHandlerImpl
:
public
TaskSet
::
ErrorHandler
{
public
:
uint
exceptionCount
=
0
;
...
...
c++/src/kj/async.h
View file @
e22e5641
...
...
@@ -294,6 +294,7 @@ private:
friend
class
_
::
NeverDone
;
template
<
typename
U
>
friend
Promise
<
Array
<
U
>>
joinPromises
(
Array
<
Promise
<
U
>>&&
promises
);
friend
Promise
<
void
>
joinPromises
(
Array
<
Promise
<
void
>>&&
promises
);
};
template
<
typename
T
>
...
...
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