mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
More std::atomic and friends
This commit is contained in:
@ -250,7 +250,7 @@ struct AddChildNodeFetchTrans {
|
||||
FVaultAddChildNodeCallback callback;
|
||||
void * cbParam;
|
||||
ENetError result;
|
||||
long opCount;
|
||||
std::atomic<long> opCount;
|
||||
|
||||
AddChildNodeFetchTrans()
|
||||
: callback(nil), cbParam(nil), result(kNetSuccess), opCount(0) { }
|
||||
@ -1019,12 +1019,11 @@ void AddChildNodeFetchTrans::VaultNodeRefsFetched (
|
||||
param,
|
||||
&incFetchCount
|
||||
);
|
||||
AtomicAdd(&trans->opCount, incFetchCount);
|
||||
trans->opCount += incFetchCount;
|
||||
}
|
||||
|
||||
// Make the callback now if there are no nodes to fetch, or if error
|
||||
AtomicAdd(&trans->opCount, -1);
|
||||
if (!trans->opCount) {
|
||||
if (!(--trans->opCount)) {
|
||||
if (trans->callback)
|
||||
trans->callback(
|
||||
trans->result,
|
||||
@ -1046,9 +1045,8 @@ void AddChildNodeFetchTrans::VaultNodeFetched (
|
||||
|
||||
if (IS_NET_ERROR(result))
|
||||
trans->result = result;
|
||||
|
||||
AtomicAdd(&trans->opCount, -1);
|
||||
if (!trans->opCount) {
|
||||
|
||||
if (!(--trans->opCount)) {
|
||||
if (trans->callback)
|
||||
trans->callback(
|
||||
trans->result,
|
||||
@ -1793,13 +1791,13 @@ void VaultAddChildNode (
|
||||
// One or more nodes need to be fetched before the callback is made
|
||||
AddChildNodeFetchTrans * trans = new AddChildNodeFetchTrans(callback, param);
|
||||
if (!childLink->node->GetNodeType()) {
|
||||
AtomicAdd(&trans->opCount, 1);
|
||||
++trans->opCount;
|
||||
NetCliAuthVaultNodeFetch(
|
||||
childId,
|
||||
AddChildNodeFetchTrans::VaultNodeFetched,
|
||||
trans
|
||||
);
|
||||
AtomicAdd(&trans->opCount, 1);
|
||||
++trans->opCount;
|
||||
NetCliAuthVaultFetchNodeRefs(
|
||||
childId,
|
||||
AddChildNodeFetchTrans::VaultNodeRefsFetched,
|
||||
@ -1807,13 +1805,13 @@ void VaultAddChildNode (
|
||||
);
|
||||
}
|
||||
if (!parentLink->node->GetNodeType()) {
|
||||
AtomicAdd(&trans->opCount, 1);
|
||||
++trans->opCount;
|
||||
NetCliAuthVaultNodeFetch(
|
||||
parentId,
|
||||
AddChildNodeFetchTrans::VaultNodeFetched,
|
||||
trans
|
||||
);
|
||||
AtomicAdd(&trans->opCount, 1);
|
||||
++trans->opCount;
|
||||
NetCliAuthVaultFetchNodeRefs(
|
||||
parentId,
|
||||
AddChildNodeFetchTrans::VaultNodeRefsFetched,
|
||||
@ -2218,8 +2216,7 @@ namespace _VaultFetchNodesAndWait {
|
||||
) {
|
||||
::VaultNodeFetched(result, nil, node);
|
||||
|
||||
long * nodeCount = (long *)param;
|
||||
AtomicAdd(nodeCount, -1);
|
||||
--(*reinterpret_cast<std::atomic<unsigned>*>(param));
|
||||
}
|
||||
|
||||
} // namespace _VaultFetchNodesAndWait
|
||||
@ -2231,20 +2228,21 @@ void VaultFetchNodesAndWait (
|
||||
) {
|
||||
using namespace _VaultFetchNodesAndWait;
|
||||
|
||||
long nodeCount = (long)count;
|
||||
std::atomic<unsigned> nodeCount(count);
|
||||
|
||||
for (unsigned i = 0; i < count; ++i) {
|
||||
|
||||
if (!force) {
|
||||
// See if we already have this node
|
||||
if (RelVaultNodeLink * link = s_nodes.Find(nodeIds[i])) {
|
||||
AtomicAdd(&nodeCount, -1);
|
||||
--nodeCount;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Start fetching the node
|
||||
NetCliAuthVaultNodeFetch(nodeIds[i], _VaultNodeFetched, (void *)&nodeCount);
|
||||
// Start fetching the node
|
||||
NetCliAuthVaultNodeFetch(nodeIds[i], _VaultNodeFetched,
|
||||
reinterpret_cast<void *>(&nodeCount));
|
||||
}
|
||||
|
||||
while (nodeCount) {
|
||||
|
Reference in New Issue
Block a user