Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8476703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:15:12+00:00 2026-06-10T18:15:12+00:00

I have request objects with corresponding response objects. Sender object makes a request and

  • 0

I have request objects with corresponding response objects. Sender object makes a request and then listens for response. One sender/listener object may send different requests. Every request goes into a global queue and after it was processed, corresponding response is sent to every listener object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:15:14+00:00Added an answer on June 10, 2026 at 6:15 pm

    There are several solutions to your problem. One would be, that the transceiver informs all Request object about its destruction. For this, you would need a method like
    Transceiver::addRequest() which a Request object uses to register itself. In the
    destructor of Transceiver you have to inform all registered Request‘s. For example:

    class Transceiver
    {
        virtual ~Transceiver()
        {
            for (auto request : m_requests)
                request->deleteTransceiver(this);
        }
    
        void addRequest(Request* r)
        {
            m_requests.push_back(r);
        }
    
        void removeRequest(Request* r)
        {
            m_requests.erase(std::remove(m_requests.begin(), m_requests.end(), r), 
                             m_requests.end());
        }
    
        std::vector<Request*> m_requests;
    };
    
    class Request
    {
        virtual void deleteTransceiver(Transceiver* t) = 0;
        virtual void notify() = 0;
    };
    
    class RequestImpl : public Request
    {
        RequestImpl(Transceiver* t)
            : m_target(t)
        {
            if (t)
                t->addRequest(this);
        }
    
        ~RequestImpl()
        {
            if (m_target)
                m_target->removeRequest(this);
        }
    
        virtual void deleteTransceiver(Transceiver* t)
        {
            if (m_target == t)
                m_target = 0;
        }
    
        virtual void notify() 
        { 
            if (m_target)
                m_target->process(ResponseType()); 
        }
    
        Transceiver* m_target;
    };
    

    A second approach would of course be to prevent the destruction of a Transceiver as
    long as it is in use. You could use a std::shared_ptr<Transceiver> m_target in the
    Request class, which means the transceiver lives at least as long as the associated request.

    For a bit more flexibility, there is also the possibility of an std::weak_ptr<Transceiver>. Then the transceiver could be destroyed when the request
    is still alive. However, when you try a std::weak_ptr<Transceiver>::lock() and it
    fails, you know that the Transceiver is dead.

    Edit: Added a method to remove a Request if it is destroyed before its Transceiver.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a relatively simple object with a method that makes an HTTP request.
In my django views i have the following def create(request): query=header.objects.filter(id=a)[0] a=query.criteria_set.all() logging.debug(a.details) I
I have a hierarchy of objects define as follows: class Request { RequestType type
I have a function like this: def eventcateg_detail(request): ca = EventTypeCategory.objects.values() for i in
I've created a object that I'd like to have accessible from wherever the request-object
I have an object in my controller @data=<meta property=\og:url\ content=\<%=SITE_URL%><%=request.request_uri%>\ />.html_safe When I print
I have a soap request returning array of User objects. Now I want to
My questions are: In Struts2, does every action object have its own corresponding ActionContext
I have request where i need to change grid formatting on drop down action
I have 100 web servers and noticed that some of them have request filtering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.