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
d475caca
Commit
d475caca
authored
Nov 15, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GCC.
parent
51c2b855
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
async.h
c++/src/kj/async.h
+26
-12
No files found.
c++/src/kj/async.h
View file @
d475caca
...
...
@@ -686,27 +686,17 @@ public:
// Get the EventLoop in which this value can be modified.
template
<
typename
Func
>
PromiseForResult
<
Func
,
T
&>
applyNow
(
Func
&&
func
)
const
KJ_WARN_UNUSED_RESULT
{
PromiseForResult
<
Func
,
T
&>
applyNow
(
Func
&&
func
)
const
KJ_WARN_UNUSED_RESULT
;
// Calls the given function, passing the guarded object to it as a mutable reference, and
// returning a pointer to the function's result. When called from within the object's event
// loop, the function runs synchronously, but when called from any other thread, the function
// is queued to run on the object's loop later.
if
(
loop
.
isCurrent
())
{
return
func
(
const_cast
<
T
&>
(
value
));
}
else
{
return
applyLater
(
kj
::
fwd
<
Func
>
(
func
));
}
}
template
<
typename
Func
>
PromiseForResult
<
Func
,
T
&>
applyLater
(
Func
&&
func
)
const
KJ_WARN_UNUSED_RESULT
{
PromiseForResult
<
Func
,
T
&>
applyLater
(
Func
&&
func
)
const
KJ_WARN_UNUSED_RESULT
;
// Like `applyNow` but always queues the function to run later regardless of which thread
// called it.
return
loop
.
evalLater
(
Capture
<
Func
>
{
const_cast
<
T
&>
(
value
),
kj
::
fwd
<
Func
>
(
func
)
});
}
private
:
const
EventLoop
&
loop
;
T
value
;
...
...
@@ -1597,6 +1587,30 @@ PromiseFulfillerPair<T> newPromiseAndFulfiller(const EventLoop& loop) {
return
PromiseFulfillerPair
<
T
>
{
kj
::
mv
(
promise
),
kj
::
mv
(
wrapper
)
};
}
template
<
typename
T
>
template
<
typename
Func
>
PromiseForResult
<
Func
,
T
&>
EventLoopGuarded
<
T
>::
applyNow
(
Func
&&
func
)
const
{
// Calls the given function, passing the guarded object to it as a mutable reference, and
// returning a pointer to the function's result. When called from within the object's event
// loop, the function runs synchronously, but when called from any other thread, the function
// is queued to run on the object's loop later.
if
(
loop
.
isCurrent
())
{
return
func
(
const_cast
<
T
&>
(
value
));
}
else
{
return
applyLater
(
kj
::
fwd
<
Func
>
(
func
));
}
}
template
<
typename
T
>
template
<
typename
Func
>
PromiseForResult
<
Func
,
T
&>
EventLoopGuarded
<
T
>::
applyLater
(
Func
&&
func
)
const
{
// Like `applyNow` but always queues the function to run later regardless of which thread
// called it.
return
loop
.
evalLater
(
Capture
<
Func
>
{
const_cast
<
T
&>
(
value
),
kj
::
fwd
<
Func
>
(
func
)
});
}
}
// namespace kj
#endif // KJ_ASYNC_H_
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