mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-24 19:26:04 +00:00
3b662122f9
* troposphere: add haze MTP server * haze: adjust banner, new lines between class sections, single-statement if * haze: remove additional newlines between sections * haze: avoid use of reference out parameter * haze: console_main_loop: style * haze: event_reactor, file_system_proxy, ptp: style * haze: ptp_data_builder, ptp_object_database, ptp_object_heap, results, usb_session: style * haze: event_reactor, ptp_data_parser, async_usb_server, ptp_object_database, ptp_object_heap: style * haze: ptp_responder: style * haze: usb_session: style * haze: use svc defs from vapours * haze: misc comments * haze: fix pointer overflow check * haze: fix copy paste error * haze: use alignment, invalidate cached use values in console * haze: fix stray hex constant * haze: misc style * haze: fixes for windows * haze: add GetObjectPropsSupported, GetObjectPropDesc, GetObjectPropValue * haze: add SetObjectPropValue * haze: improve object database API * haze: improve WriteVariableLengthData readability * haze: fix directory renames on windows * haze: ptp_object_database: fix collation * haze: event_reactor: fix size validation * haze: ptp_responder: improve documentation * haze: ptp_responder: avoid unnecessary fs interaction in GetObjectPropValue * haze: ptp_responder: fix object deletion on windows * haze: tear down sessions on suspension * haze: prefer more specific data types * haze: misc * haze: fix usb 3.0 support * haze: improve host-to-device file transfer performance * haze: report device serial * haze: move static_assert to requires, fix alignment
52 lines
1.9 KiB
C++
52 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) Atmosphère-NX
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <haze/common.hpp>
|
|
|
|
namespace haze {
|
|
|
|
class EventConsumer {
|
|
public:
|
|
virtual ~EventConsumer() = default;
|
|
virtual void ProcessEvent() = 0;
|
|
};
|
|
|
|
class EventReactor {
|
|
private:
|
|
EventConsumer *m_consumers[svc::ArgumentHandleCountMax];
|
|
Waiter m_waiters[svc::ArgumentHandleCountMax];
|
|
s32 m_num_wait_objects;
|
|
Result m_result;
|
|
public:
|
|
constexpr explicit EventReactor() : m_consumers(), m_waiters(), m_num_wait_objects(), m_result(ResultSuccess()) { /* ... */ }
|
|
|
|
bool AddConsumer(EventConsumer *consumer, Waiter waiter);
|
|
void RemoveConsumer(EventConsumer *consumer);
|
|
public:
|
|
void SetResult(Result r) { m_result = r; }
|
|
Result GetResult() const { return m_result; }
|
|
public:
|
|
template <typename... Args> requires (sizeof...(Args) > 0)
|
|
Result WaitFor(s32 *out_arg_waiter, Args &&... arg_waiters) {
|
|
const Waiter arg_waiter_array[] = { arg_waiters... };
|
|
return this->WaitForImpl(out_arg_waiter, arg_waiter_array, sizeof...(Args));
|
|
}
|
|
private:
|
|
Result WaitForImpl(s32 *out_arg_waiter, const Waiter *arg_waiters, s32 num_arg_waiters);
|
|
};
|
|
|
|
}
|