libstrat: convert to experimental new (super-accurate) sf allocation semantics

This commit is contained in:
Michael Scire
2021-01-17 07:55:32 -08:00
parent 8314d015f3
commit 8956e3bd29
149 changed files with 2852 additions and 1746 deletions

View File

@@ -18,33 +18,33 @@
namespace ams::pwm::server {
ManagerImpl::ManagerImpl() : session_memory_resource(), allocator(std::addressof(session_memory_resource)) {
ManagerImpl::ManagerImpl() {
this->heap_handle = lmem::CreateExpHeap(this->heap_buffer, sizeof(this->heap_buffer), lmem::CreateOption_None);
this->session_memory_resource.Attach(this->heap_handle);
this->allocator.Attach(this->heap_handle);
}
ManagerImpl::~ManagerImpl() {
lmem::DestroyExpHeap(this->heap_handle);
}
Result ManagerImpl::OpenSessionForDev(ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, int channel) {
Result ManagerImpl::OpenSessionForDev(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, int channel) {
/* TODO */
AMS_ABORT();
}
Result ManagerImpl::OpenSession(ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name) {
Result ManagerImpl::OpenSession(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name) {
return this->OpenSession2(out, ConvertToDeviceCode(channel_name));
}
Result ManagerImpl::OpenSession2(ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, DeviceCode device_code) {
Result ManagerImpl::OpenSession2(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, DeviceCode device_code) {
/* Allocate a session. */
auto session = ams::sf::AllocateShared<pwm::sf::IChannelSession, ChannelSessionImpl>(this->allocator, this);
auto session = Factory::CreateSharedEmplaced<pwm::sf::IChannelSession, ChannelSessionImpl>(std::addressof(this->allocator), this);
/* Open the session. */
R_TRY(session->GetImpl().OpenSession(device_code));
R_TRY(session.GetImpl().OpenSession(device_code));
/* We succeeded. */
out.SetValue(std::move(session));
*out = std::move(session);
return ResultSuccess();
}