| 97 | } |
| 98 | |
| 99 | bool sugoi::scheduler_t::sync_entry(sugoi::archetype_t* type, sugoi_type_index_t i, bool readonly) |
| 100 | { |
| 101 | SKR_ASSERT(is_main_thread(type->storage)); |
| 102 | // TODO: performance optimization |
| 103 | skr::stl_vector<skr::task::event_t> deps; |
| 104 | |
| 105 | { |
| 106 | SMutexLock entryLock(entryMutex.mMutex); |
| 107 | auto pair = dependencyEntries.find(type); |
| 108 | if (pair == dependencyEntries.end()) |
| 109 | return false; |
| 110 | auto entries = pair->second.data(); |
| 111 | for (auto dep : entries[i].owned) |
| 112 | if(auto ptr = dep.lock()) |
| 113 | deps.push_back(ptr); |
| 114 | if(!readonly) |
| 115 | { |
| 116 | for (auto p : entries[i].shared) |
| 117 | if(auto ptr = p.lock()) |
| 118 | deps.push_back(ptr); |
| 119 | entries[i].shared.clear(); |
| 120 | } |
| 121 | entries[i].owned.clear(); |
| 122 | } |
| 123 | |
| 124 | for (auto dep : deps) |
| 125 | dep.wait(true); |
| 126 | return !deps.empty(); |
| 127 | } |
| 128 | |
| 129 | bool sugoi::scheduler_t::sync_query(sugoi_query_t* query) |
| 130 | { |