equal
deleted
inserted
replaced
34 #include "config.h" |
34 #include "config.h" |
35 #include "suggestion.h" |
35 #include "suggestion.h" |
36 #include "testutils.h" |
36 #include "testutils.h" |
37 #include "testcorpus.h" |
37 #include "testcorpus.h" |
38 #include "setupsentry.h" |
38 #include "setupsentry.h" |
39 |
39 #include "testutils.h" |
40 #include "std_log_result.h" |
40 #include "std_log_result.h" |
41 |
41 |
42 // TODO PROPER, EXAMPLARY error clearing (cpix_ClearError()) |
42 // TODO PROPER, EXAMPLARY error clearing (cpix_ClearError()) |
43 |
43 |
44 |
44 |
585 } |
585 } |
586 |
586 |
587 |
587 |
588 bool call(cpix_Hits * hits, |
588 bool call(cpix_Hits * hits, |
589 int32_t index, |
589 int32_t index, |
590 cpix_Document * target, |
590 cpix_Document ** target, |
591 Itk::TestMgr * testMgr, |
591 Itk::TestMgr * testMgr, |
592 bool cancel) |
592 bool cancel) |
593 { |
593 { |
594 bool |
594 bool |
595 rv = false; |
595 rv = false; |
603 |
603 |
604 jobId = cpix_Hits_asyncDoc(hits, |
604 jobId = cpix_Hits_asyncDoc(hits, |
605 index, |
605 index, |
606 target, |
606 target, |
607 this, |
607 this, |
608 &callback); |
608 &callback, |
|
609 1); |
609 } |
610 } |
610 |
611 |
611 ITK_ASSERT(testMgr, |
612 ITK_ASSERT(testMgr, |
612 ReportIfFailed(testMgr, |
613 ReportIfFailed(testMgr, |
613 hits, |
614 hits, |
723 { |
724 { |
724 Cpt::SyncQueue<cpix_JobId> q_; |
725 Cpt::SyncQueue<cpix_JobId> q_; |
725 |
726 |
726 SyncedDoc syncedDoc_; |
727 SyncedDoc syncedDoc_; |
727 |
728 |
728 cpix_Document targetDoc_; |
729 cpix_Document **targetDoc_; |
729 |
730 |
730 Cpt::Mutex & cpixMutex_; |
731 Cpt::Mutex & cpixMutex_; |
731 |
732 |
732 public: |
733 public: |
733 |
734 |
734 SyncedSearch(Cpt::Mutex & cpixMutex) |
735 SyncedSearch(Cpt::Mutex & cpixMutex) |
735 : q_(1), |
736 : q_(1), |
736 syncedDoc_(cpixMutex), |
737 syncedDoc_(cpixMutex), |
737 cpixMutex_(cpixMutex) |
738 cpixMutex_(cpixMutex) |
738 { |
739 { |
739 ; |
740 ALLOC_DOC(targetDoc_, 1); |
740 } |
741 } |
741 |
742 |
|
743 ~SyncedSearch() { |
|
744 FREE_DOC(targetDoc_, 1); |
|
745 } |
|
746 |
742 void call(cpix_IdxSearcher * searcher, |
747 void call(cpix_IdxSearcher * searcher, |
743 cpix_Query * query, |
748 cpix_Query * query, |
744 Itk::TestMgr * testMgr, |
749 Itk::TestMgr * testMgr, |
745 bool cancel) |
750 bool cancel) |
746 { |
751 { |
903 for (int32_t i = 0; i < SOME && i < length; ++i) |
908 for (int32_t i = 0; i < SOME && i < length; ++i) |
904 { |
909 { |
905 bool |
910 bool |
906 succeeded = syncedDoc_.call(hits, |
911 succeeded = syncedDoc_.call(hits, |
907 i, |
912 i, |
908 &targetDoc_, |
913 targetDoc_, |
909 testMgr, |
914 testMgr, |
910 (i%4) == 1); // cancel or not |
915 (i%4) == 1); // cancel or not |
911 |
916 |
912 if (succeeded) |
917 if (succeeded) |
913 { |
918 { |
914 Cpt::SyncRegion |
919 Cpt::SyncRegion |
915 sr(cpixMutex_); |
920 sr(cpixMutex_); |
916 |
921 |
917 PrintHit(&targetDoc_, |
922 PrintHit(targetDoc_[0], |
918 testMgr); |
923 testMgr); |
919 } |
924 } |
920 } |
925 } |
921 } |
926 } |
922 |
927 |