55 bool has_waiting_sync =
false;
56 int waiting_count = 0;
57 for (
auto& keyValuePair :
m_map) {
58 MiscNode_TBE&
tbe = keyValuePair.second;
60 switch (
tbe.getstate()) {
61 case MiscNode_State_DvmSync_Distributing:
62 case MiscNode_State_DvmNonSync_Distributing:
65 case MiscNode_State_DvmSync_ReadyToDist:
66 ready_sync_tbes.push_back(&
tbe);
68 case MiscNode_State_DvmNonSync_ReadyToDist:
69 ready_nonsync_tbes.push_back(&
tbe);
71 potential_sync_dependency_tbes.push_back(&
tbe);
73 case MiscNode_State_DvmSync_Waiting:
74 has_waiting_sync =
true;
77 case MiscNode_State_DvmNonSync_Waiting:
80 potential_sync_dependency_tbes.push_back(&
tbe);
90 assert(waiting_count <= 4);
91 if (waiting_count == 4) {
96 if (has_waiting_sync) {
97 ready_sync_tbes.clear();
105 auto hasNonSyncDependency = [&](
const MiscNode_TBE* sync_tbe) {
106 for (
const auto* potential_dep : potential_sync_dependency_tbes) {
107 if (sync_tbe->gettimestamp() > potential_dep->gettimestamp() &&
108 sync_tbe->getrequestor() == potential_dep->getrequestor()) {
120 ready_sync_tbes.erase(
121 std::remove_if(ready_sync_tbes.begin(), ready_sync_tbes.end(),
122 hasNonSyncDependency),
123 ready_sync_tbes.end()
129 ready_nonsync_tbes.insert(ready_nonsync_tbes.end(),
130 ready_sync_tbes.begin(), ready_sync_tbes.end());
133 if (ready_nonsync_tbes.empty())
137 auto it = std::min_element(
138 ready_nonsync_tbes.begin(), ready_nonsync_tbes.end(),
139 [](
const MiscNode_TBE*
a,
const MiscNode_TBE*
b) {
140 return a->gettimestamp() - b->gettimestamp();
143 assert(it != ready_nonsync_tbes.end());