searchengine/cpix/cpix/src/cpix_async.cpp
changeset 14 8bd192d47aaa
parent 0 671dee74050a
equal deleted inserted replaced
13:fcb2a58c181b 14:8bd192d47aaa
  1105         //
  1105         //
  1106         // private members
  1106         // private members
  1107         //
  1107         //
  1108         cpix_Hits      * hits_;
  1108         cpix_Hits      * hits_;
  1109         int32_t          index_;
  1109         int32_t          index_;
  1110         cpix_Document  * target_;
  1110         cpix_Document  ** target_;
       
  1111         int32_t          count_;
  1111 
  1112 
  1112 
  1113 
  1113     public:
  1114     public:
  1114         //
  1115         //
  1115         // public operators
  1116         // public operators
  1116         //
  1117         //
  1117         static cpix_JobId CreateJob(cpix_Hits          * hits,
  1118         static cpix_JobId CreateJob(cpix_Hits          * hits,
  1118                                     int32_t              index,
  1119                                     int32_t              index,
  1119                                     cpix_Document      * target,
  1120                                     cpix_Document      ** target,
  1120                                     void               * cookie,
  1121                                     void               * cookie,
  1121                                     cpix_AsyncCallback * callback)
  1122                                     cpix_AsyncCallback * callback,
       
  1123                                     int32_t              count)
  1122         {
  1124         {
  1123             std::auto_ptr<AsyncJob>
  1125             std::auto_ptr<AsyncJob>
  1124                 job(new AsyncHitsDocJob(hits,
  1126                 job(new AsyncHitsDocJob(hits,
  1125                                         index,
  1127                                         index,
  1126                                         target,
  1128                                         target,
  1127                                         cookie,
  1129                                         cookie,
  1128                                         callback));
  1130                                         callback,
       
  1131                                         count ));
  1129 
  1132 
  1130             cpix_JobId
  1133             cpix_JobId
  1131                 rv = job->id();
  1134                 rv = job->id();
  1132 
  1135 
  1133             PutAsyncJobToQueue(job,
  1136             PutAsyncJobToQueue(job,
  1165         //
  1168         //
  1166         // lifetime management
  1169         // lifetime management
  1167         //
  1170         //
  1168         AsyncHitsDocJob(cpix_Hits          * hits,
  1171         AsyncHitsDocJob(cpix_Hits          * hits,
  1169                         int32_t              index,
  1172                         int32_t              index,
  1170                         cpix_Document      * target,
  1173                         cpix_Document      ** target,
  1171                         void               * cookie,
  1174                         void               * cookie,
  1172                         cpix_AsyncCallback * callback)
  1175                         cpix_AsyncCallback * callback,
       
  1176                         int32_t              count)
  1173             : AsyncJob(IdxDbHndl(), // default value for handlers
  1177             : AsyncJob(IdxDbHndl(), // default value for handlers
  1174                        cookie,
  1178                        cookie,
  1175                        callback),
  1179                        callback),
  1176               hits_(NULL),
  1180               hits_(NULL),
  1177               index_(index),
  1181               index_(index),
  1178               target_(target)
  1182               target_(target),
       
  1183               count_(count)
  1179         {
  1184         {
  1180             // We must make sure that these native objects live even
  1185             // We must make sure that these native objects live even
  1181             // if the client calls cancel in the middle of operation
  1186             // if the client calls cancel in the middle of operation
  1182             // and discards the argument right after cancel.
  1187             // and discards the argument right after cancel.
  1183 
  1188 
  1215             hits.ptr_ = hits_->ptr_;
  1220             hits.ptr_ = hits_->ptr_;
  1216             hits.err_ = NULL;
  1221             hits.err_ = NULL;
  1217 
  1222 
  1218             cpix_Hits_doc(&hits,
  1223             cpix_Hits_doc(&hits,
  1219                           index_,
  1224                           index_,
  1220                           target_);
  1225                           target_,
       
  1226                           count_);
  1221 
  1227 
  1222             return hits.err_;
  1228             return hits.err_;
  1223         }
  1229         }
  1224 
  1230 
  1225     };
  1231     };
  1839 }
  1845 }
  1840 
  1846 
  1841 
  1847 
  1842 cpix_JobId cpix_Hits_asyncDoc(cpix_Hits          * thisHits,
  1848 cpix_JobId cpix_Hits_asyncDoc(cpix_Hits          * thisHits,
  1843                               int32_t              index,
  1849                               int32_t              index,
  1844                               cpix_Document      * target,
  1850                               cpix_Document      ** target,
  1845                               void               * cookie,
  1851                               void               * cookie,
  1846                               cpix_AsyncCallback * callback)
  1852                               cpix_AsyncCallback * callback,
       
  1853                               int32_t              count)
  1847 {
  1854 {
  1848     return XlateExc(thisHits,
  1855     return XlateExc(thisHits,
  1849                     CallFreeFunc(&AsyncHitsDocJob::CreateJob,
  1856                     CallFreeFunc(&AsyncHitsDocJob::CreateJob,
  1850                                  thisHits,
  1857                                  thisHits,
  1851                                  index,
  1858                                  index,
  1852                                  target,
  1859                                  target,
  1853                                  cookie,
  1860                                  cookie,
  1854                                  callback));
  1861                                  callback,
       
  1862                                  count));
  1855 }
  1863 }
  1856 
  1864 
  1857 
  1865 
  1858 void cpix_Hits_asyncDocResults(cpix_Hits * thisHits,
  1866 void cpix_Hits_asyncDocResults(cpix_Hits * thisHits,
  1859                                cpix_JobId  jobId)
  1867                                cpix_JobId  jobId)