Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/Loader.h
/* Copyright (C) 2009 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
// - if the entire task was successfully completed, return 0; | // - if the entire task was successfully completed, return 0; | ||||
// it will then be de-queued. | // it will then be de-queued. | ||||
// - if the work can be split into smaller subtasks, process those until | // - if the work can be split into smaller subtasks, process those until | ||||
// <time_left> is reached or exceeded and then return an estimate | // <time_left> is reached or exceeded and then return an estimate | ||||
// of progress in percent (<= 100, otherwise it's a warning; | // of progress in percent (<= 100, otherwise it's a warning; | ||||
// != 0, or it's treated as "finished") | // != 0, or it's treated as "finished") | ||||
// - on failure, return a negative error code or 'warning' (see above); | // - on failure, return a negative error code or 'warning' (see above); | ||||
// LDR_ProgressiveLoad will abort immediately and return that. | // LDR_ProgressiveLoad will abort immediately and return that. | ||||
typedef int (*LoadFunc)(void* param, double time_left); | typedef int (*LoadFunc)(std::shared_ptr<void> param, double time_left); | ||||
// register a task (later processed in FIFO order). | // register a task (later processed in FIFO order). | ||||
// <func>: function that will perform the actual work; see LoadFunc. | // <func>: function that will perform the actual work; see LoadFunc. | ||||
// <param>: (optional) parameter/persistent state; must be freed by func. | // <param>: (optional) parameter/persistent state. | ||||
// <description>: user-visible description of the current task, e.g. | // <description>: user-visible description of the current task, e.g. | ||||
// "Loading Textures". | // "Loading Textures". | ||||
// <estimated_duration_ms>: used to calculate progress, and when checking | // <estimated_duration_ms>: used to calculate progress, and when checking | ||||
// whether there is enough of the time budget left to process this task | // whether there is enough of the time budget left to process this task | ||||
// (reduces timeslice overruns, making the main loop more responsive). | // (reduces timeslice overruns, making the main loop more responsive). | ||||
extern void LDR_Register(LoadFunc func, void* param, const wchar_t* description, | extern void LDR_Register(LoadFunc func, std::shared_ptr<void> param, const wchar_t* description, | ||||
int estimated_duration_ms); | int estimated_duration_ms); | ||||
// call when finished registering tasks; subsequent calls to | // call when finished registering tasks; subsequent calls to | ||||
// LDR_ProgressiveLoad will then work off the queued entries. | // LDR_ProgressiveLoad will then work off the queued entries. | ||||
extern void LDR_EndRegistering(); | extern void LDR_EndRegistering(); | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator