【问题标题】:How to manage callback functions using thread,mutex or other ways如何使用线程、互斥或其他方式管理回调函数
【发布时间】:2016-12-13 06:48:19
【问题描述】:
void __stdcall callbackfunction(){message}

int main() {
    NotifytoServer(&callbackfunction);
    for (int i=0 ;i<3;++i) {
        AskServer();
    }

    //using messages from callbackfunction
}

每次我调用 AskServer 函数时,对方(服务器)都会给我发送一些消息。

1.如果我调用AskServer,有一个问题是我不知道回调函数的时间(请看附图)。

2.我如何使用一些编程技术(boost::thread,mutex.etc)来等待我每次AskServer获取消息?

【问题讨论】:

    标签: c++ multithreading visual-c++ boost callback


    【解决方案1】:

    也许您可以使用条件变量来同步线程? http://en.cppreference.com/w/cpp/thread/condition_variable

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多