mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibCore+Userland+Tests: Convert Stream APIs to construct on heap
As per previous discussion, it was decided that the Stream classes should be constructed on the heap. While I don't personally agree with this change, it does have the benefit of avoiding Function object reconstructions due to the lambda passed to Notifier pointing to a stale object reference. This also has the benefit of not having to "box" objects for virtual usage, as the objects come pre-boxed. However, it means that we now hit the heap everytime we construct a TCPSocket for instance, which might not be desirable.
This commit is contained in:
parent
eb389db92c
commit
dbd25916a3
14 changed files with 163 additions and 162 deletions
|
@ -17,12 +17,12 @@
|
|||
|
||||
class Client : public RefCounted<Client> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Client>> create(int id, Core::Stream::TCPSocket socket, int ptm_fd);
|
||||
static ErrorOr<NonnullRefPtr<Client>> create(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd);
|
||||
|
||||
Function<void()> on_exit;
|
||||
|
||||
private:
|
||||
Client(int id, Core::Stream::TCPSocket socket, int ptm_fd);
|
||||
Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd);
|
||||
|
||||
ErrorOr<void> drain_socket();
|
||||
ErrorOr<void> drain_pty();
|
||||
|
@ -38,7 +38,7 @@ private:
|
|||
// client id
|
||||
int m_id { 0 };
|
||||
// client resources
|
||||
Core::Stream::TCPSocket m_socket;
|
||||
NonnullOwnPtr<Core::Stream::TCPSocket> m_socket;
|
||||
Parser m_parser;
|
||||
// pty resources
|
||||
int m_ptm_fd { -1 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue