event queue: Structure size efficiency

This commit is contained in:
Eladash 2021-05-08 20:08:25 +03:00 committed by Ivan
parent 7a4918e4a4
commit 31b55e0030
9 changed files with 23 additions and 23 deletions

View file

@ -11,13 +11,13 @@
LOG_CHANNEL(sys_event); LOG_CHANNEL(sys_event);
lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, u64 name, u64 ipc_key, s32 size) noexcept lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64 ipc_key) noexcept
: protocol{protocol} : id(idm::last_id())
, id(idm::last_id()) , protocol{static_cast<u8>(protocol)}
, type(type) , type(static_cast<u8>(type))
, size(static_cast<u8>(size))
, name(name) , name(name)
, key(ipc_key) , key(ipc_key)
, size(size)
{ {
} }
@ -127,7 +127,7 @@ error_code sys_event_queue_create(cpu_thread& cpu, vm::ptr<u32> equeue_id, vm::p
if (const auto error = lv2_obj::create<lv2_event_queue>(pshared, ipc_key, flags, [&]() if (const auto error = lv2_obj::create<lv2_event_queue>(pshared, ipc_key, flags, [&]()
{ {
return std::make_shared<lv2_event_queue>(protocol, type, name, ipc_key, size); return std::make_shared<lv2_event_queue>(protocol, type, size, name, ipc_key);
})) }))
{ {
return error; return error;

View file

@ -80,18 +80,18 @@ struct lv2_event_queue final : public lv2_obj
{ {
static const u32 id_base = 0x8d000000; static const u32 id_base = 0x8d000000;
const lv2_protocol protocol;
const u32 id; const u32 id;
const s32 type; const lv2_protocol protocol;
const u8 type;
const u8 size;
const u64 name; const u64 name;
const u64 key; const u64 key;
const s32 size;
shared_mutex mutex; shared_mutex mutex;
std::deque<lv2_event> events; std::deque<lv2_event> events;
std::deque<cpu_thread*> sq; std::deque<cpu_thread*> sq;
lv2_event_queue(u32 protocol, s32 type, u64 name, u64 ipc_key, s32 size) noexcept; lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64 ipc_key) noexcept;
CellError send(lv2_event); CellError send(lv2_event);

View file

@ -45,8 +45,8 @@ struct lv2_event_flag final : lv2_obj
atomic_t<u64> pattern; atomic_t<u64> pattern;
std::deque<cpu_thread*> sq; std::deque<cpu_thread*> sq;
lv2_event_flag(u32 protocol, u64 key, s32 type, u64 name, u64 pattern) lv2_event_flag(u32 protocol, u64 key, s32 type, u64 name, u64 pattern) noexcept
: protocol{protocol} : protocol{static_cast<u8>(protocol)}
, key(key) , key(key)
, type(type) , type(type)
, name(name) , name(name)

View file

@ -34,10 +34,10 @@ struct lv2_lwcond final : lv2_obj
atomic_t<u32> waiters{0}; atomic_t<u32> waiters{0};
std::deque<cpu_thread*> sq; std::deque<cpu_thread*> sq;
lv2_lwcond(u64 name, u32 lwid, u32 protocol, vm::ptr<sys_lwcond_t> control) lv2_lwcond(u64 name, u32 lwid, u32 protocol, vm::ptr<sys_lwcond_t> control) noexcept
: name(std::bit_cast<be_t<u64>>(name)) : name(std::bit_cast<be_t<u64>>(name))
, lwid(lwid) , lwid(lwid)
, protocol{protocol} , protocol{static_cast<u8>(protocol)}
, control(control) , control(control)
{ {
} }

View file

@ -64,8 +64,8 @@ struct lv2_lwmutex final : lv2_obj
std::deque<cpu_thread*> sq; std::deque<cpu_thread*> sq;
atomic_t<s32> lwcond_waiters{0}; atomic_t<s32> lwcond_waiters{0};
lv2_lwmutex(u32 protocol, vm::ptr<sys_lwmutex_t> control, u64 name) lv2_lwmutex(u32 protocol, vm::ptr<sys_lwmutex_t> control, u64 name) noexcept
: protocol{protocol} : protocol{static_cast<u8>(protocol)}
, control(control) , control(control)
, name(std::bit_cast<be_t<u64>>(name)) , name(std::bit_cast<be_t<u64>>(name))
{ {

View file

@ -37,8 +37,8 @@ struct lv2_mutex final : lv2_obj
atomic_t<u32> lock_count{0}; // Recursive Locks atomic_t<u32> lock_count{0}; // Recursive Locks
std::deque<cpu_thread*> sq; std::deque<cpu_thread*> sq;
lv2_mutex(u32 protocol, u32 recursive,u32 adaptive, u64 key, u64 name) lv2_mutex(u32 protocol, u32 recursive,u32 adaptive, u64 key, u64 name) noexcept
: protocol{protocol} : protocol{static_cast<u8>(protocol)}
, recursive(recursive) , recursive(recursive)
, adaptive(adaptive) , adaptive(adaptive)
, key(key) , key(key)

View file

@ -32,8 +32,8 @@ struct lv2_rwlock final : lv2_obj
std::deque<cpu_thread*> rq; std::deque<cpu_thread*> rq;
std::deque<cpu_thread*> wq; std::deque<cpu_thread*> wq;
lv2_rwlock(u32 protocol, u64 key, u64 name) lv2_rwlock(u32 protocol, u64 key, u64 name) noexcept
: protocol{protocol} : protocol{static_cast<u8>(protocol)}
, key(key) , key(key)
, name(name) , name(name)
{ {

View file

@ -32,8 +32,8 @@ struct lv2_sema final : lv2_obj
atomic_t<s32> val; atomic_t<s32> val;
std::deque<cpu_thread*> sq; std::deque<cpu_thread*> sq;
lv2_sema(u32 protocol, u64 key, u64 name, s32 max, s32 value) lv2_sema(u32 protocol, u64 key, u64 name, s32 max, s32 value) noexcept
: protocol{protocol} : protocol{static_cast<u8>(protocol)}
, key(key) , key(key)
, name(name) , name(name)
, max(max) , max(max)

View file

@ -14,7 +14,7 @@
#include <thread> #include <thread>
// attr_protocol (waiting scheduling policy) // attr_protocol (waiting scheduling policy)
enum lv2_protocol : u32 enum lv2_protocol : u8
{ {
SYS_SYNC_FIFO = 0x1, // First In, First Out Order SYS_SYNC_FIFO = 0x1, // First In, First Out Order
SYS_SYNC_PRIORITY = 0x2, // Priority Order SYS_SYNC_PRIORITY = 0x2, // Priority Order