mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-22 04:25:19 +00:00
IdManager fix
This commit is contained in:
parent
591a6c8671
commit
ee173dc3a2
3 changed files with 31 additions and 48 deletions
|
@ -737,12 +737,6 @@ struct fs_aio_thread : ppu_thread
|
|||
struct fs_aio_manager
|
||||
{
|
||||
std::shared_ptr<fs_aio_thread> thread;
|
||||
|
||||
fs_aio_manager()
|
||||
: thread(idm::make_ptr<ppu_thread, fs_aio_thread>("FS AIO Thread", 500))
|
||||
{
|
||||
thread->run();
|
||||
}
|
||||
};
|
||||
|
||||
s32 cellFsAioInit(vm::cptr<char> mount_point)
|
||||
|
@ -750,7 +744,13 @@ s32 cellFsAioInit(vm::cptr<char> mount_point)
|
|||
cellFs.warning("cellFsAioInit(mount_point=%s)", mount_point);
|
||||
|
||||
// TODO: create AIO thread (if not exists) for specified mount point
|
||||
fxm::get_always<fs_aio_manager>();
|
||||
const auto m = fxm::make<fs_aio_manager>();
|
||||
|
||||
if (m)
|
||||
{
|
||||
m->thread = idm::make_ptr<ppu_thread, fs_aio_thread>("FS AIO Thread", 500);
|
||||
m->thread->run();
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -772,9 +772,14 @@ s32 cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
|
|||
|
||||
// TODO: detect mount point and send AIO request to the AIO thread of this mount point
|
||||
|
||||
const s32 xid = (*id = ++g_fs_aio_id);
|
||||
const auto m = fxm::get<fs_aio_manager>();
|
||||
|
||||
const auto m = fxm::get_always<fs_aio_manager>();
|
||||
if (!m)
|
||||
{
|
||||
return CELL_ENXIO;
|
||||
}
|
||||
|
||||
const s32 xid = (*id = ++g_fs_aio_id);
|
||||
|
||||
m->thread->cmd_list
|
||||
({
|
||||
|
@ -793,9 +798,14 @@ s32 cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
|
|||
|
||||
// TODO: detect mount point and send AIO request to the AIO thread of this mount point
|
||||
|
||||
const s32 xid = (*id = ++g_fs_aio_id);
|
||||
const auto m = fxm::get<fs_aio_manager>();
|
||||
|
||||
const auto m = fxm::get_always<fs_aio_manager>();
|
||||
if (!m)
|
||||
{
|
||||
return CELL_ENXIO;
|
||||
}
|
||||
|
||||
const s32 xid = (*id = ++g_fs_aio_id);
|
||||
|
||||
m->thread->cmd_list
|
||||
({
|
||||
|
|
|
@ -64,39 +64,18 @@ id_manager::id_map::pointer idm::allocate_id(std::pair<u32, u32> types, u32 base
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
id_manager::id_map::pointer idm::find_id(u32 type, u32 id)
|
||||
{
|
||||
auto& map = g_map[type];
|
||||
|
||||
const auto found = map.find(id);
|
||||
|
||||
return found == map.end() ? nullptr : std::addressof(*found);
|
||||
}
|
||||
|
||||
id_manager::id_map::pointer idm::find_id(u32 type, u32 true_type, u32 id)
|
||||
{
|
||||
auto& map = g_map[type];
|
||||
|
||||
const auto found = map.find(id);
|
||||
|
||||
return found == map.end() || found->first.type() != true_type ? nullptr : std::addressof(*found);
|
||||
}
|
||||
|
||||
std::shared_ptr<void> idm::delete_id(u32 type, u32 id)
|
||||
{
|
||||
auto& map = g_map[type];
|
||||
|
||||
const auto found = map.find(id);
|
||||
|
||||
std::shared_ptr<void> result;
|
||||
|
||||
if (found != map.end())
|
||||
if (found != map.end() && (type == true_type || found->first.type() == true_type))
|
||||
{
|
||||
result = std::move(found->second);
|
||||
map.erase(found);
|
||||
return std::addressof(*found);
|
||||
}
|
||||
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<void> idm::delete_id(u32 type, u32 true_type, u32 id)
|
||||
|
@ -107,7 +86,7 @@ std::shared_ptr<void> idm::delete_id(u32 type, u32 true_type, u32 id)
|
|||
|
||||
std::shared_ptr<void> result;
|
||||
|
||||
if (found != map.end() && found->first.type() == true_type)
|
||||
if (found != map.end() && (type == true_type || found->first.type() == true_type))
|
||||
{
|
||||
result = std::move(found->second);
|
||||
map.erase(found);
|
||||
|
|
|
@ -232,16 +232,10 @@ class idm
|
|||
// Prepare new ID (returns nullptr if out of resources)
|
||||
static id_manager::id_map::pointer allocate_id(std::pair<u32, u32> types, u32 base, u32 step, u32 count);
|
||||
|
||||
// Remove ID and return the object
|
||||
static std::shared_ptr<void> delete_id(u32 type, u32 id);
|
||||
|
||||
// Remove ID and return the object (check type)
|
||||
// Remove ID and return the object (additionally check true_type if not equal)
|
||||
static std::shared_ptr<void> delete_id(u32 type, u32 true_type, u32 id);
|
||||
|
||||
// Get ID
|
||||
static id_manager::id_map::pointer find_id(u32 type, u32 id);
|
||||
|
||||
// Get ID (check type)
|
||||
// Get ID (additionally check true_type if not equal)
|
||||
static id_manager::id_map::pointer find_id(u32 type, u32 true_type, u32 id);
|
||||
|
||||
// Allocate new ID and assign the object from the provider()
|
||||
|
@ -267,7 +261,7 @@ class idm
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
delete_id(types.first, place->first.id());
|
||||
delete_id(types.first, types.first, place->first.id());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +482,7 @@ public:
|
|||
}
|
||||
|
||||
// Get count of objects
|
||||
template<typename T, typename Get = T>
|
||||
template<typename T, typename Get = void>
|
||||
static inline u32 get_count()
|
||||
{
|
||||
reader_lock lock(id_manager::g_mutex);
|
||||
|
@ -558,7 +552,7 @@ public:
|
|||
|
||||
func(*static_cast<Get*>(found->second.get()));
|
||||
|
||||
ptr = delete_id(get_type<T>(), id);
|
||||
ptr = delete_id(get_type<T>(), get_type<Get>(), id);
|
||||
|
||||
g_map[get_type<T>()].erase(id);
|
||||
}
|
||||
|
@ -595,7 +589,7 @@ public:
|
|||
return result_type{{found->second, _ptr}, std::move(ret)};
|
||||
}
|
||||
|
||||
ptr = delete_id(get_type<T>(), id);
|
||||
ptr = delete_id(get_type<T>(), get_type<Get>(), id);
|
||||
|
||||
g_map[get_type<T>()].erase(id);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue