How to connect different parts of the application?

Hi!

Im trying to make c++ programs.

When my program starts, program creates 2 threads:
-- in first thread (LoginScreen class) goes main program loop. This loop has auth form with login and password field and submit button. When user clicked on button, the data by socket connection submitted to server program, by the way submit button translates to disabled status;
-- second thread needs to work with socket -- it listen socket, dispatch packets and handle them.

My problem -- I dont know how to forward the received packet about successful authorization to the LoginScreen.

Today I learned mediator pattern ( https://sourcemaking.com/design_patterns/mediator/cpp/1 ), but I dont know how implement it to my program -- when program has two threads and this parts so different.

I also think about static class like Singleton with getInstance method, but I can not imagine how, especially due to the fact that he has a lot of logic:

public:
LoginScreen();
virtual void onAttach() override;
virtual void onDetach() override;
void onUpdate() override;
void onEvent(Event& event) override;


What I need to do?
Make the data visible to both threads.

It doesn't have to be direct sharing, but the idea's the same.

And as always, when accessing the same thing from different threads, access must be synchronised.
Make the data visible to both threads.

how?
Topic archived. No new replies allowed.