| 63 | } |
| 64 | |
| 65 | bool sugoi::scheduler_t::sync_archetype(sugoi::archetype_t* type) |
| 66 | { |
| 67 | SKR_ASSERT(is_main_thread(type->storage)); |
| 68 | // TODO: performance optimization |
| 69 | skr::stl_vector<skr::task::event_t> deps; |
| 70 | { |
| 71 | SMutexLock entryLock(entryMutex.mMutex); |
| 72 | auto pair = dependencyEntries.find(type); |
| 73 | if (pair == dependencyEntries.end()) |
| 74 | { |
| 75 | return false; |
| 76 | } |
| 77 | auto entries = pair->second.data(); |
| 78 | auto count = type->type.length; |
| 79 | forloop (i, 0, count) |
| 80 | { |
| 81 | if (type_index_t(type->type.data[i]).is_tag()) |
| 82 | break; |
| 83 | for (auto dep : entries[i].owned) |
| 84 | if(auto ptr = dep.lock()) |
| 85 | deps.push_back(ptr); |
| 86 | for (auto p : entries[i].shared) |
| 87 | if(auto ptr = p.lock()) |
| 88 | deps.push_back(ptr); |
| 89 | entries[i].shared.clear(); |
| 90 | entries[i].owned.clear(); |
| 91 | } |
| 92 | dependencyEntries.erase(pair); |
| 93 | } |
| 94 | for (auto dep : deps) |
| 95 | dep.wait(true); |
| 96 | return !deps.empty(); |
| 97 | } |
| 98 | |
| 99 | bool sugoi::scheduler_t::sync_entry(sugoi::archetype_t* type, sugoi_type_index_t i, bool readonly) |
| 100 | { |
no test coverage detected