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
2d1c9a53
Commit
2d1c9a53
authored
Nov 28, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove a bunch of mutexes.
parent
bf7af0b6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
40 deletions
+25
-40
rpc-test.c++
c++/src/capnp/rpc-test.c++
+1
-1
rpc.c++
c++/src/capnp/rpc.c++
+0
-0
async.c++
c++/src/kj/async.c++
+7
-11
async.h
c++/src/kj/async.h
+17
-28
No files found.
c++/src/capnp/rpc-test.c++
View file @
2d1c9a53
...
...
@@ -161,7 +161,7 @@ private:
}
private
:
mutable
kj
::
Vector
<
kj
::
String
>
caps
;
kj
::
Vector
<
kj
::
String
>
caps
;
};
};
...
...
c++/src/capnp/rpc.c++
View file @
2d1c9a53
This diff is collapsed.
Click to expand it.
c++/src/kj/async.c++
View file @
2d1c9a53
...
...
@@ -560,25 +560,22 @@ void TransformPromiseNodeBase::getDepResult(ExceptionOrValue& output) {
// -------------------------------------------------------------------
ForkBranchBase
::
ForkBranchBase
(
Own
<
ForkHubBase
>&&
hubParam
)
:
hub
(
kj
::
mv
(
hubParam
))
{
auto
lock
=
hub
->
branchList
.
lockExclusive
();
if
(
lock
->
lastPtr
==
nullptr
)
{
if
(
hub
->
tailBranch
==
nullptr
)
{
onReadyEvent
.
arm
();
}
else
{
// Insert into hub's linked list of branches.
prevPtr
=
lock
->
lastPtr
;
prevPtr
=
hub
->
tailBranch
;
*
prevPtr
=
this
;
next
=
nullptr
;
lock
->
lastPtr
=
&
next
;
hub
->
tailBranch
=
&
next
;
}
}
ForkBranchBase
::~
ForkBranchBase
()
noexcept
(
false
)
{
if
(
prevPtr
!=
nullptr
)
{
// Remove from hub's linked list of branches.
auto
lock
=
hub
->
branchList
.
lockExclusive
();
*
prevPtr
=
next
;
(
next
==
nullptr
?
lock
->
lastPtr
:
next
->
prevPtr
)
=
prevPtr
;
(
next
==
nullptr
?
hub
->
tailBranch
:
next
->
prevPtr
)
=
prevPtr
;
}
}
...
...
@@ -618,16 +615,15 @@ Maybe<Own<EventLoop::Event>> ForkHubBase::fire() {
resultRef
.
addException
(
kj
::
mv
(
*
exception
));
}
auto
lock
=
branchList
.
lockExclusive
();
for
(
auto
branch
=
lock
->
first
;
branch
!=
nullptr
;
branch
=
branch
->
next
)
{
for
(
auto
branch
=
headBranch
;
branch
!=
nullptr
;
branch
=
branch
->
next
)
{
branch
->
hubReady
();
*
branch
->
prevPtr
=
nullptr
;
branch
->
prevPtr
=
nullptr
;
}
*
lock
->
lastPtr
=
nullptr
;
*
tailBranch
=
nullptr
;
// Indicate that the list is no longer active.
lock
->
lastPtr
=
nullptr
;
tailBranch
=
nullptr
;
return
nullptr
;
}
...
...
c++/src/kj/async.h
View file @
2d1c9a53
...
...
@@ -1108,16 +1108,12 @@ public:
inline
ExceptionOrValue
&
getResultRef
()
{
return
resultRef
;
}
private
:
struct
BranchList
{
ForkBranchBase
*
first
=
nullptr
;
ForkBranchBase
**
lastPtr
=
&
first
;
};
Own
<
PromiseNode
>
inner
;
ExceptionOrValue
&
resultRef
;
MutexGuarded
<
BranchList
>
branchList
;
// Becomes null once the inner promise is ready and all branches have been notified.
ForkBranchBase
*
headBranch
=
nullptr
;
ForkBranchBase
**
tailBranch
=
&
headBranch
;
// Tail becomes null once the inner promise is ready and all branches have been notified.
Maybe
<
Own
<
Event
>>
fire
()
override
;
_
::
PromiseNode
*
getInnerForTrace
()
override
;
...
...
@@ -1451,61 +1447,54 @@ public:
}
void
fulfill
(
FixVoid
<
T
>&&
value
)
override
{
auto
lock
=
inner
.
lockExclusive
();
if
(
*
lock
!=
nullptr
)
{
(
*
lock
)
->
fulfill
(
kj
::
mv
(
value
));
if
(
inner
!=
nullptr
)
{
inner
->
fulfill
(
kj
::
mv
(
value
));
}
}
void
reject
(
Exception
&&
exception
)
override
{
auto
lock
=
inner
.
lockExclusive
();
if
(
*
lock
!=
nullptr
)
{
(
*
lock
)
->
reject
(
kj
::
mv
(
exception
));
if
(
inner
!=
nullptr
)
{
inner
->
reject
(
kj
::
mv
(
exception
));
}
}
bool
isWaiting
()
override
{
auto
lock
=
inner
.
lockExclusive
();
return
*
lock
!=
nullptr
&&
(
*
lock
)
->
isWaiting
();
return
inner
!=
nullptr
&&
inner
->
isWaiting
();
}
void
attach
(
PromiseFulfiller
<
T
>&
newInner
)
{
inner
.
getWithoutLock
()
=
&
newInner
;
inner
=
&
newInner
;
}
void
detach
(
PromiseFulfiller
<
T
>&
from
)
{
auto
lock
=
inner
.
lockExclusive
();
if
(
*
lock
==
nullptr
)
{
if
(
inner
==
nullptr
)
{
// Already disposed.
lock
.
release
();
delete
this
;
}
else
{
KJ_IREQUIRE
(
*
lock
==
&
from
);
*
lock
=
nullptr
;
KJ_IREQUIRE
(
inner
==
&
from
);
inner
=
nullptr
;
}
}
private
:
MutexGuarded
<
PromiseFulfiller
<
T
>*>
inner
;
mutable
PromiseFulfiller
<
T
>*
inner
;
WeakFulfiller
()
:
inner
(
nullptr
)
{}
void
disposeImpl
(
void
*
pointer
)
const
override
{
// TODO(perf): Factor some of this out so it isn't regenerated for every fulfiller type?
auto
lock
=
inner
.
lockExclusive
();
if
(
*
lock
==
nullptr
)
{
if
(
inner
==
nullptr
)
{
// Already detached.
lock
.
release
();
delete
this
;
}
else
{
if
(
(
*
lock
)
->
isWaiting
())
{
(
*
lock
)
->
reject
(
kj
::
Exception
(
if
(
inner
->
isWaiting
())
{
inner
->
reject
(
kj
::
Exception
(
kj
::
Exception
::
Nature
::
LOCAL_BUG
,
kj
::
Exception
::
Durability
::
PERMANENT
,
__FILE__
,
__LINE__
,
kj
::
heapString
(
"PromiseFulfiller was destroyed without fulfilling the promise."
)));
}
*
lock
=
nullptr
;
inner
=
nullptr
;
}
}
};
...
...
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