Remove IServer client ref

This commit is contained in:
TuxSH 2018-11-09 00:01:48 +01:00 committed by Michael Scire
parent 1b3b26c3af
commit 195da2e599
5 changed files with 13 additions and 4 deletions

View file

@ -22,7 +22,7 @@ class IClientServerParent : public IClientServerParentTag {
{
Parent *par = (Parent *)this;
client.SetParent(par);
server.SetParentAndClient(par, &client);
server.SetParentAndClient(par);
}
ClientClass &GetClient() { return client; }

View file

@ -23,16 +23,14 @@ class IServer : public IServerTag {
const SharedPtr<Parent> &GetParent() const { return parent; }
void SetParentAndClient(SharedPtr<Parent> parent, SharedPtr<Client> client)
void SetParentAndClient(SharedPtr<Parent> parent)
{
this->parent = std::move(parent);
this->client = std::move(client);
}
protected:
SharedPtr<Parent> parent{};
SharedPtr<Client> client{};
};
}

View file

@ -21,6 +21,11 @@ class KWritableEvent final : public KAutoObject, public IServer<KEvent, KReadabl
Result Signal();
Result Clear();
void SetClient(SharedPtr<KReadableEvent> client);
private:
SharedPtr<KReadableEvent> client{};
};
inline void intrusive_ptr_add_ref(KWritableEvent *obj)

View file

@ -11,6 +11,7 @@ KEvent::~KEvent()
Result KEvent::Initialize()
{
SetClientServerParent();
server.SetClient(&client);
SetResourceOwner(KCoreContext::GetCurrentInstance().GetCurrentProcess());
return ResultSuccess();

View file

@ -19,4 +19,9 @@ Result KWritableEvent::Clear()
return client->Clear();
}
void KWritableEvent::SetClient(SharedPtr<KReadableEvent> client)
{
this->client = std::move(client);
}
}