- Add Support for Downloading Data/Files, do Api Requests
- Refactor Tasks System
  - Now uses std::thread
- The Net  Functions Will Break IDBN server for now
This commit is contained in:
2024-05-22 22:16:40 +02:00
parent a0923acec7
commit 6d7781b209
9 changed files with 415 additions and 39 deletions

View File

@@ -16,26 +16,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <3ds.h>
#include <stdio.h>
#include <string.h>
#include <memory>
#include <renderd7/Tasks.hpp>
#include <thread>
#include <vector>
static std::vector<Thread> threads;
static std::vector<std::shared_ptr<std::thread>> threads;
void RenderD7::Tasks::create(ThreadFunc entrypoint) {
s32 prio = 0;
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
Thread thread = threadCreate((ThreadFunc)entrypoint, NULL, 64 * 1024,
prio - 1, -2, false);
threads.push_back(thread);
int RenderD7::Tasks::Create(std::function<void()> fun) {
auto thrd = std::make_shared<std::thread>(fun);
threads.push_back(thrd);
return threads.size();
}
void RenderD7::Tasks::destroy(void) {
for (u32 i = 0; i < threads.size(); i++) {
threadJoin(threads.at(i), U64_MAX);
threadFree(threads.at(i));
void RenderD7::Tasks::DestroyAll() {
for (auto& it : threads) {
if (it && it->joinable()) {
it->join();
}
}
// Delete Pointers
threads.clear();
}