Last active
January 4, 2017 21:58
-
-
Save abhiguru/68041ef47969bb63b7a375aee99d1c93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(){ | |
... | |
std::thread videoProcTH([&]{ | |
EventBase evb; | |
ClassA *aclass = new ClassA(&evb); | |
evb.loopForever(); | |
}); | |
} | |
class classA{ | |
... | |
classA::requestData(fbstring url, std::function<void(fbstring)> callback){ | |
evb->runInEventBaseThread([=]() { | |
CurlClient *curlClient = new CurlClient(evb, fbcurl, callback); | |
HTTPConnector *connector_ = new HTTPConnector(curlClient, timer_.get()); | |
static const AsyncSocket::OptionMap opts{{{SOL_SOCKET, SO_REUSEADDR}, 1}}; | |
if (url.isSecure()) { | |
connector_->connectSSL( | |
evb, *addr, sslContext_, nullptr, | |
std::chrono::milliseconds(12000), opts, | |
folly::AsyncSocket::anyAddress(), curlClient->getServerName()); | |
} else { | |
connector_->connect(evb, *addr, std::chrono::milliseconds(12000), opts); | |
} | |
}); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, there was another thread leading to the requestData which is why runInBaseThread was required.