Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: How sessions are handled in listener

$
0
0
I defined my class as follows:

class GenderClassifier
{
public:
GenderClassifier(utility::string_t url, GenderIdOptions gender_id_options);

pplx::task<void> open() { return m_listener.open(); }
pplx::task<void> close() { return m_listener.close(); }
private:
void handle_get(http_request message);
void handle_put(http_request message);
void handle_post(http_request message);
void handle_delete(http_request message);

http_listener m_listener;
GenderId gender_id_;
};

and the GenderId object consumes a lot of memory and need not be duplicated for each context. In main I do the following (in initialize)
g_GenderClassifier = std::unique_ptr<GenderClassifier>(new GenderClassifier(addr,gender_id_options));
g_GenderClassifier->open().wait();
So I am just double-checking that the same class is passed as a reference to each of the threads invoking / handling the "handle_post" , "handle_get" etc.

On the other hand, there are some items that need to persist between multiple put calls of the same session, and need to be destroyed when the session expires. Where should I put those?
thanks

Viewing all articles
Browse latest Browse all 4845


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>