[*] Update asynctypes.hpp header, added hashcode and equals operator to two types that should've had them defined already.

This commit is contained in:
Reece Wilson 2022-06-01 20:16:55 +01:00
parent b500c0bd5f
commit 056ffc4b68

View File

@ -38,17 +38,27 @@ namespace Aurora::Async
struct WorkerId_t : AuPair<ThreadGroup_t, ThreadId_t>
{
WorkerId_t() : AuPair<ThreadGroup_t, ThreadId_t>(0, 0)
inline WorkerId_t() : AuPair<ThreadGroup_t, ThreadId_t>(0, 0)
{}
WorkerId_t(ThreadGroup_t group) : AuPair<ThreadGroup_t, ThreadId_t>(group, kThreadIdAny)
inline WorkerId_t(ThreadGroup_t group) : AuPair<ThreadGroup_t, ThreadId_t>(group, kThreadIdAny)
{}
WorkerId_t(ThreadGroup_t group, ThreadId_t id) : AuPair<ThreadGroup_t, ThreadId_t>(group, id)
inline WorkerId_t(ThreadGroup_t group, ThreadId_t id) : AuPair<ThreadGroup_t, ThreadId_t>(group, id)
{}
WorkerId_t(const WorkerId_t &cpy) : AuPair<ThreadGroup_t, ThreadId_t>(cpy.first, cpy.second)
inline WorkerId_t(const WorkerId_t &cpy) : AuPair<ThreadGroup_t, ThreadId_t>(cpy.first, cpy.second)
{}
inline AuUInt HashCode() const noexcept
{
return AuHashCode(AuUInt(this->first) << 20 | AuUInt(this->second));
}
bool operator==(const WorkerId_t &in) const noexcept
{
return in.first == this->first && this->second == in.second;
}
};
struct WorkPriv
@ -58,21 +68,31 @@ namespace Aurora::Async
struct WorkerPId_t : WorkerId_t
{
WorkerPId_t()
inline WorkerPId_t()
{}
WorkerPId_t(const AuSPtr<IThreadPool> &pool, ThreadGroup_t group) : WorkerId_t(group, kThreadIdAny), pool(pool)
inline WorkerPId_t(const AuSPtr<IThreadPool> &pool, ThreadGroup_t group) : WorkerId_t(group, kThreadIdAny), pool(pool)
{}
WorkerPId_t(const AuSPtr<IThreadPool> &pool, ThreadGroup_t group, ThreadId_t id) : WorkerId_t(group, id), pool(pool)
inline WorkerPId_t(const AuSPtr<IThreadPool> &pool, ThreadGroup_t group, ThreadId_t id) : WorkerId_t(group, id), pool(pool)
{}
WorkerPId_t(const AuSPtr<IThreadPool> &pool, const WorkerId_t &cpy) : WorkerId_t(cpy.first, cpy.second), pool(pool)
inline WorkerPId_t(const AuSPtr<IThreadPool> &pool, const WorkerId_t &cpy) : WorkerId_t(cpy.first, cpy.second), pool(pool)
{}
AuSPtr<IThreadPool> pool;
operator bool() const
inline AuUInt HashCode() const noexcept
{
return AuHashCode(AuUInt(this->first) << 20 | AuUInt(this->second)) ^ AuHashCode(pool.get());
}
bool operator==(const WorkerPId_t & in) const noexcept
{
return in.pool == this->pool && in.first == this->first && this->second == in.second;
}
inline operator bool() const
{
return pool;
}