ext/revdispatch/libdispatch-0.1/src/ev_dispatch.cc in evdispatch-0.1.3 vs ext/revdispatch/libdispatch-0.1/src/ev_dispatch.cc in evdispatch-0.1.4
- old
+ new
@@ -181,30 +181,16 @@
ASSERT_IS_D_THRAD
//printf("timeout cb\n");
}
// called on the main thread, not the event loop thread
-request_t Dispatch::request( Request::Type type, const std::string &url )
+request_t Dispatch::request( Request *req )
{
request_t key = m_counter++;
- Request *req = NULL;
- // check the request type and
- switch( type ) {
- case Request::HTTP:
- req = new HttpRequest( m_http_client, key, url );
- break;
- case Request::SPHINX:
- //req = new SphinxRequest( key, url );
- break;
- case Request::MEMCACHED:
- break;
- default:
- // TODO: log an error
- break;
- }
- m_requests.push( req );
- ev_async_send( m_loop, &m_request_watcher );
- return key;
+ req->set_key( key );
+ m_requests.push( req ); // load the request into the request queue
+ ev_async_send( m_loop, &m_request_watcher ); // signal to the event loop we have new requests pending
+ return key; // return to the client a unique identifier for matching up the response to this request
}
Response *Dispatch::response_for( request_t id )
{
RespondedTable::iterator loc = m_responded.find(id);