Member function problem

Discussion in 'C++' started by adalat, Sep 2, 2010.

  1. adalat

    adalat New Member

    Joined:
    Sep 2, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have a problem with member functions and nested classes which I am stumped on.

    Basically I want to set up a thread which can access a specific instance method from the calling class

    The code is set up like this:

    ServiceImplClass.cpp - > gets a message, and usually services a request by building a reply and sending it using a function (SendMessage) from its BaseClass (Service.h). In this specific case I want to set up a thread (which can be in the form of a nested class in ServiceImplClass.cpp) which can send off a message every x seconds, without blocking the main thread.

    I can't seem to find a way to allow this. I understand that you can usually pass a function pointer to the new class/thread to allow access to the function. However I can only have one instance of the service running at one time due to some design specific issues, which mean I have to send all messages out through that instance.


    class Service -------> void SendMessage()
    |
    |
    |
    class ServiceImplClass --------> class SimpleThread



    Does anyone have any tricks I could use here. I'm sure it's something which is staring me in the face!

    Many thanks :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice