1 #ifndef STREAMITER__HPP
2 #define STREAMITER__HPP
46 #include <condition_variable>
57 #if defined(NCBI_THREADS)
60 template<
typename TRoot>
138 template<
typename...>
160 template<
typename TObj>
165 template<
typename TObj>
176 m_Index = index; m_FnFilter = fn; m_Extra = extra;
return *
this;
180 m_Index = ns_ObjectIStreamFilterIterator::xxx_MemberIndex<TObj>(mem_name);
181 m_FnFilter = fn; m_Extra = extra;
return *
this;
202 template<
typename TObj>
205 const CParams<TObj>& params = CParams<TObj>()) =
delete;
335 template<
typename...>
341 template<
typename TObj>
346 template<
typename TR>
350 : m_ThreadPolicy(launch::async)
351 , m_MaxParserThreads (16)
352 , m_MaxTotalRawSize (16 * 1024 * 1024)
353 , m_MinRawBufferSize (128 * 1024)
354 , m_SameThread(
false) {
359 CParent::FilterByMember(index, fn, extra);
return *
this;
364 CParent::FilterByMember(mem_name, fn, extra);
return *
this;
369 m_ThreadPolicy = policy;
return *
this;
374 m_MaxParserThreads = max_parser_threads;
return *
this;
379 m_MaxTotalRawSize = max_total_raw_size;
return *
this;
384 m_MinRawBufferSize = min_raw_buffer_size;
return *
this;
395 m_SameThread = same_thread;
return *
this;
420 template<
typename TObj>
423 const CParams<TObj>& params = CParams<TObj>()) =
delete;
475 template<
typename TRoot>
514 void x_BeginRead(
void);
515 void x_EndRead(
void);
519 bool x_NextSeqWithFilter(
const CObjectInfo& objinfo);
520 bool x_NextChoiceWithFilter(
const CObjectInfo& objinfo);
521 bool x_NextContainerWithFilter(
const CObjectInfo& objinfo);
546 template<
typename TR>
564 void x_ReaderThread(
void);
571 template<
typename TRoot,
typename TChild>
593 void x_ReaderThread(
void);
595 template<
typename TR>
604 m_This->x_AcceptData(
in,
type);
617 template<
typename TRoot>
621 return TRoot::GetTypeInfo();
624 template<
typename TRoot>
632 template<
typename TRoot>
635 TTypeInfo tinfo = xxx_GetTypeInfo<TRoot>();
647 template<
typename...>
648 template<
typename TObj>
651 TTypeInfo tinfo = ns_ObjectIStreamFilterIterator::xxx_GetTypeInfo<TObj>();
665 template<
typename TRoot>
670 template<
typename TRoot>
673 : m_Data( new CData(istr, deleteInStream, params,
677 template<
typename TRoot>
682 if (m_Data->m_FilterType !=
CData::eNone && !m_Data->m_EndOfData) {
683 m_Data->m_HasReader =
true;
684 m_Data->m_Reader = thread([
this](){x_ReaderThread();});
689 template<
typename TRoot>
694 template<
typename TRoot>
701 template<
typename TRoot>
705 template<
typename TRoot>
709 : m_Istr(&istr), m_Own(deleteInStream)
710 , m_ValueType(tinfo), m_Value(tinfo), m_HasReader(
false)
711 , m_EndOfData(m_Istr->EndOfData()), m_Params(params)
715 m_Params.m_FnFilter =
nullptr;
717 m_FilterType =
eNone;
718 if (m_Params.m_FnFilter) {
728 if (m_FilterType ==
eNone) {
731 m_FilterType = is_random ? eOneRandom : eOneSeq;
733 m_FilterType = is_random ? eAllRandom : eAllSeq;
737 m_FilterType = m_Params.m_Index !=
kInvalidMember ? eOneChoice : eAllChoice;
739 m_FilterType = m_Params.m_Index !=
kInvalidMember ? eOneContainer : eAllContainer;
744 template<
typename TRoot>
746 if (m_Reader.joinable()) {
748 m_ReaderCv.notify_all();
756 template<
typename TRoot>
759 unique_lock<mutex> lck( m_ReaderMutex);
760 while (m_Value.GetObjectPtr() !=
nullptr) {
761 m_ReaderCv.wait(lck);
765 template<
typename TRoot>
770 m_ReaderCv.notify_one();
773 template<
typename TRoot>
776 m_Data->x_BeginRead();
778 m_Data->m_ValueType.SetLocalSkipHook(*(m_Data->m_Istr),
new typename CData::template x_CObjectIStreamIteratorHook<TRoot>(m_Data.get()));
782 if (!m_Data->m_EndOfData) {
783 m_Data->m_ReaderExpt = current_exception();
789 template<
typename TRoot,
typename TChild>
792 this->m_Data->x_BeginRead();
794 this->m_Data->m_ValueType.SetLocalSkipHook(*(this->m_Data->m_Istr),
new typename CParent::CData::template x_CObjectIStreamIteratorHook<TChild>(this->m_Data.get()));
795 this->m_Data->m_ValueType.SetLocalReadHook(*(this->m_Data->m_Istr),
new x_CObjectIStreamIteratorReadHook<TChild>(this->m_Data.get()));
799 if (!this->m_Data->m_EndOfData) {
800 this->m_Data->m_ReaderExpt = current_exception();
803 this->m_Data->x_EndRead();
806 template<
typename TRoot>
811 if (m_Istr->EndOfData()) {
815 switch ( m_FilterType) {
818 res = x_NextNoFilter(objinfo);
824 res = x_NextSeqWithFilter(objinfo);
828 res = x_NextChoiceWithFilter(objinfo);
832 res = x_NextContainerWithFilter(objinfo);
836 unique_lock<mutex> lck(m_ReaderMutex);
838 m_ReaderCv.notify_one();
839 while (m_Value.GetObjectPtr() !=
nullptr) {
842 "CObjectIStreamIterator: abort data parsing");
844 m_ReaderCv.wait(lck);
847 in.SetDiscardCurrObject();
852 template<
typename TRoot>
855 unique_lock<mutex> lck(m_ReaderMutex);
857 m_ReaderCv.notify_one();
858 while (m_Value.GetObjectPtr() ==
nullptr && !m_EndOfData) {
859 m_ReaderCv.wait(lck);
862 rethrow_exception(m_ReaderExpt);
866 template<
typename TRoot>
874 template<
typename TRoot>
880 bool checked =
false;
891 switch (m_FilterType) {
897 if (mi_now > m_Params.m_Index && !checked) {
898 valid = m_Params.m_FnFilter( *m_Istr, obj, m_Params.m_Index,
nullptr, m_Params.m_Extra);
903 for (++mi; valid && mi < mi_now; ++mi) {
904 valid = m_Params.m_FnFilter( *m_Istr, obj, mi,
nullptr, m_Params.m_Extra);
913 i.ReadClassMember(objinfo);
916 switch (m_FilterType) {
920 if (mi_now == m_Params.m_Index) {
923 valid = m_Params.m_FnFilter( *m_Istr, obj, mi_now, &oi, m_Params.m_Extra);
935 valid = m_Params.m_FnFilter( *m_Istr, obj, mi_now, &oi, m_Params.m_Extra);
948 switch (m_FilterType) {
953 valid = m_Params.m_FnFilter( *m_Istr, obj, m_Params.m_Index,
nullptr, m_Params.m_Extra);
959 for (++mi; valid && mi < mi_last; ++mi) {
960 valid = m_Params.m_FnFilter( *m_Istr, obj, mi,
nullptr, m_Params.m_Extra);
968 for (; valid && mi < mi_last; ++mi) {
970 valid = m_Params.m_FnFilter( *m_Istr, obj, mi,
nullptr, m_Params.m_Extra);
980 template<
typename TRoot>
989 if (
i == m_Params.m_Index) {
992 valid = m_Params.m_FnFilter( *m_Istr, obj,
i, &oi, m_Params.m_Extra);
994 valid = m_Params.m_FnFilter( *m_Istr, obj, m_Params.m_Index,
nullptr, m_Params.m_Extra);
999 template<
typename TRoot>
1012 if (m_FilterType == eAllContainer || (m_FilterType == eOneContainer && mi == m_Params.m_Index)) {
1014 valid = m_Params.m_FnFilter( *m_Istr, obj, mi, &oe, m_Params.m_Extra);
1024 template<
typename TRoot>
1027 if (m_Data.get() !=
nullptr) {
1028 if (!m_Data->m_HasReader) {
1029 if (m_Data->m_Istr->EndOfData()) {
1032 m_Data->m_Value =
CObjectInfo(m_Data->m_ValueType);
1033 m_Data->m_Istr->Read(m_Data->m_Value);
1037 if (m_Data->m_EndOfData) {
1045 template<
typename TRoot>
1049 return m_Data.get() == v.m_Data.get();
1052 template<
typename TRoot>
1056 return m_Data.get() != v.m_Data.get();
1059 template<
typename TRoot>
1061 return m_Data.get() !=
nullptr && m_Data->m_Value.GetObjectPtr() !=
nullptr;
1064 template<
typename TRoot>
1067 return *(m_Data->m_Istr);
1070 template<
typename TRoot>
1073 return *(TRoot*)(m_Data->m_Value.GetObjectPtr());
1076 template<
typename TRoot>
1079 return IsValid() ? (TRoot*)m_Data->m_Value.GetObjectPtr() :
nullptr;
1082 template<
typename TRoot>
1088 template<
typename TRoot>
1098 template<
typename TRoot,
typename TChild>
1103 template<
typename TRoot,
typename TChild>
1106 :
CParent(istr, params, deleteInStream)
1108 if (!this->m_Data->m_EndOfData) {
1109 this->m_Data->m_HasReader =
true;
1110 this->m_Data->m_Reader = thread([
this](){x_ReaderThread();});
1115 template<
typename TRoot,
typename TChild>
1120 template<
typename TRoot,
typename TChild>
1124 CParent::operator=(v);
1128 template<
typename TRoot,
typename TChild>
1132 template<
typename TRoot,
typename TChild>
1135 CParent::operator++();
1139 template<
typename TRoot,
typename TChild>
1145 template<
typename TRoot,
typename TChild>
1155 template<
typename TRoot>
1180 TRoot* operator->();
1188 #if NCBI_COMPILER_MSVC && _MSC_VER < 1900
1216 void x_UpdateObjectsQueue();
1217 void x_UpdateFuturesQueue();
1219 void x_ReaderThread(
void);
1249 template<
typename TRoot,
typename TChild>
1287 template<
typename TRoot>
1293 template<
typename TRoot>
1302 template<
typename TRoot>
1306 : m_Data(new CData(istr, deleteInStream, parser, params))
1311 template<
typename TRoot>
1318 template<
typename TRoot>
1326 template<
typename TRoot>
1330 template<
typename TRoot>
1333 if (m_Data.get() !=
nullptr) {
1335 m_Data->x_UpdateFuturesQueue();
1336 m_Data->x_UpdateObjectsQueue();
1337 }
while (!
IsValid() && !m_Data->m_EndOfData);
1345 template<
typename TRoot>
1349 return m_Data.get() == v.m_Data.get();
1352 template<
typename TRoot>
1356 return m_Data.get() != v.m_Data.get();
1359 template<
typename TRoot>
1361 return m_Data.get() !=
nullptr && !m_Data->m_ObjectsQueue.empty();
1364 template<
typename TRoot>
1367 return m_Data->m_ObjectsQueue.front().GetObject();
1370 template<
typename TRoot>
1373 return IsValid() ? m_Data->m_ObjectsQueue.front().GetPointer() :
nullptr;
1376 template<
typename TRoot>
1382 template<
typename TRoot>
1389 template<
typename TRoot>
1412 if (params.m_FnFilter) {
1417 while(!istr->EndOfData()) {
1419 istr->Read(&*
object, object->GetThisTypeInfo());
1426 template<
typename TRoot>
1431 , m_Own(deleteInStream)
1433 , m_ParserCount( params.m_MaxParserThreads != 0 ? params.m_MaxParserThreads : 16)
1434 , m_RawBufferSize( params.m_MinRawBufferSize)
1435 , m_MaxRawSize( params.m_SameThread ? 0 : params.m_MaxTotalRawSize)
1436 , m_CurrentRawSize(0)
1437 , m_Policy(params.m_ThreadPolicy)
1438 , m_EndOfData(m_Istr->EndOfData())
1441 if (m_MaxRawSize != 0 && !m_EndOfData) {
1442 m_Reader = thread([
this](){x_ReaderThread();});
1446 template<
typename TRoot>
1448 if (m_Reader.joinable()) {
1450 m_ReaderCv.notify_all();
1474 template<
typename TRoot>
1479 if(!m_ObjectsQueue.empty()) {
1480 m_GarbageQueue.push( m_ObjectsQueue.front());
1481 m_ObjectsQueue.pop();
1485 if( m_ObjectsQueue.empty()
1486 && !m_FuturesQueue.empty())
1488 m_ObjectsQueue = m_FuturesQueue.front().get();
1489 m_FuturesQueue.pop();
1493 template<
typename TRoot>
1498 if( m_FuturesQueue.size() >= m_ParserCount) {
1503 (m_MaxRawSize != 0 && m_ReaderData.empty() && !m_FuturesQueue.empty())) {
1507 if (
data.IsNull()) {
1531 swap(m_GarbageQueue, tmp_garbage_queue);
1533 m_FuturesQueue.push( async( m_Policy, m_Parser,
1534 data, m_Istr->GetDataFormat(), m_Params, std::move(tmp_garbage_queue)));
1537 template<
typename TRoot>
1541 if (m_MaxRawSize == 0) {
1543 if (m_Istr->EndOfData()) {
1550 m_Istr->SkipAnyContentObject();
1551 }
while( !m_Istr->EndOfData() && m_Istr->GetStreamPos() < endpos);
1556 unique_lock<mutex> lck(m_ReaderMutex);
1557 while (m_ReaderData.empty()) {
1558 m_ReaderCv.wait(lck);
1562 m_CurrentRawSize -= m_ReaderDataSize.front();
1563 m_ReaderDataSize.pop();
1564 m_ReaderCv.notify_one();
1568 template<
typename TRoot>
1573 while (!m_Istr->EndOfData()) {
1581 m_Istr->SkipAnyContentObject();
1582 }
while( !m_Istr->EndOfData() && m_Istr->GetStreamPos() < endpos);
1586 size_t this_buffer_size = m_Istr->GetStreamPos() - startpos;
1589 unique_lock<mutex> lck(m_ReaderMutex);
1591 while (!m_EndOfData && m_CurrentRawSize >= m_MaxRawSize) {
1592 m_ReaderCv.wait(lck);
1597 m_ReaderData.push(
data);
1598 m_ReaderDataSize.push( this_buffer_size);
1599 m_CurrentRawSize += this_buffer_size;
1600 m_ReaderCv.notify_one();
1604 m_ReaderMutex.lock();
1605 m_ReaderData.push(
data);
1606 m_ReaderDataSize.push(0);
1607 m_ReaderMutex.unlock();
1608 m_ReaderCv.notify_one();
1615 template<
typename TRoot,
typename TChild>
1621 template<
typename TRoot,
typename TChild>
1625 :
CParent(istr, deleteInStream,
1630 template<
typename TRoot,
typename TChild>
1637 template<
typename TRoot,
typename TChild>
1641 CParent::operator=(v);
1645 template<
typename TRoot,
typename TChild>
1649 template<
typename TRoot,
typename TChild>
1652 CParent::operator++();
1656 template<
typename TRoot,
typename TChild>
1662 template<
typename TRoot,
typename TChild>
1668 template<
typename TRoot,
typename TChild>
1708 template<
typename TRoot,
typename TObject>
1712 template<
typename TRoot,
typename TObject>
1720 virtual void Process(
const TObject& obj)
override;
1726 template<
typename TRoot,
typename TObject>
1744 "invalid data object received");
1796 template<
typename TRoot,
typename TObject>
1814 Serial_FilterObjects< TRoot >( this->
m_In,
1826 template<
typename TRoot,
typename TObject>
1844 Serial_FilterStdObjects< TRoot >( this->
m_In,
1855 template<
typename TRoot,
typename TObject>
1859 m_Reader.SetObject(&obj);
1863 template<
typename TRoot,
typename TObject>
1921 template<
typename TRoot,
typename TObject>
1951 template<
typename TRoot,
typename TObject>
bool operator!=(const _Ht_iterator< _Val, _Nonconst_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__x, const _Ht_iterator< _Val, _Const_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__y)
Reading (iterating through) members of the class (SET, SEQUENCE)
Reading (iterating through) elements of containers (SET OF, SEQUENCE OF).
Stream iterator for serial objects.
Stream iterator for standard type objects.
Asynchronous parsing parameters.
CObjectIStreamAsyncIterator<TRoot, TChild>
CObjectIStreamAsyncIterator<TRoot>
CObjectIStreamAsyncIterator.
CObjectIStreamIterator<TRoot, TChild>
template specializations and implementation
Read hook for a standalone object.
Root class for all serialization exceptions.
Helper hook for Serial_FilterObjects function template; User hook class should be derived from this b...
Skip hook for a standalone object.
Guard class for CObjectIStream::StartDelayBuffer/EndDelayBuffer.
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Include a standard set of the NCBI C++ Toolkit most basic headers.
bool operator==(const CEquivRange &A, const CEquivRange &B)
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_REPORT_EXCEPTION(title, ex)
Generate a report on the exception.
TMemberIndex Find(const CTempString &name) const
const CItemInfo * GetItemInfo(TMemberIndex index) const
static TMemberIndex FirstIndex(void)
TTypeInfo GetTypeInfo(void) const
TMemberIndex LastIndex(void) const
CVect2< NCBI_PROMOTE(int,U) > operator*(int v1, const CVect2< U > &v2)
size_t TMemberIndex
Type used for indexing class members and choice variants.
const TMemberIndex kInvalidMember
Special value returned from FindMember.
static const TObjectType * SafeCast(TTypeInfo type)
ESerialDataFormat
Data file format.
bool IsValid(void) const
Check whether the iterator points to a data TRUE if the iterator is constructed upon a serialization ...
queue< size_t > m_ReaderDataSize
CRef< CByteSource > EndDelayBuffer(void)
Redirect call to protected CObjectIStream After this call guarding is finished.
CObjectIStreamIterator(CObjectIStream &istr, EOwnership deleteInStream=eNoOwnership, const CParams< TObj > ¶ms=CParams< TObj >())=delete
Construct iterator upon an object serialization stream.
~CIStreamIteratorThread_Base(void)
CObjectIStreamIterator & begin(void)
Return self.
CObjectIStreamAsyncIterator<>::CParams< TChild > CParams
~CIStreamStdIterator(void)
CParams & FilterByMember(const string &mem_name, FMemberFilter< TObj > fn, void *extra=nullptr)
Filter by member name.
TObjectsQueue m_GarbageQueue
friend class CObjectIStreamIterator
shared_ptr< CData > m_Data
condition_variable m_ReaderCv
shared_ptr< CData > m_Data
CIStreamIteratorThread_Base< TRoot, TObject > & m_Reader
unsigned m_MaxParserThreads
x_CObjectIStreamIteratorReadHook(typename CObjectIStreamIterator< TR >::CData *pthis)
CObjectInfo GetPointedObject(void) const
Get data and type information of object to which this type refers.
CObjectIStreamIterator & operator=(const CObjectIStreamIterator &)
bool IsValid(void) const
Check whether the iterator points to a data TRUE if the iterator is constructed upon a serialization ...
~CObjectIStreamAsyncIterator()
void SetObject(const TObject *obj)
CParams & ReadAndSkipInTheSameThread(bool same_thread)
Raw data read and its pre-parsing (storing the raw data pertaining to a single object and putting it ...
function< bool(const CObjectIStream &istr, TObj &obj, TMemberIndex mem_index, CObjectInfo *mem, void *extra)> FMemberFilter
Object member filtering function.
~CObjectIStreamIterator()
const TObject * operator->(void) const
CIStreamStdIteratorThread(CObjectIStream &in, EOwnership deleteInStream)
typename CParent::TObjectsQueue TObjectsQueue
queue< future_queue_t > futures_queue_t
bool operator!=(const CObjectIStreamIterator &) const
static CObjectIStream * Create(ESerialDataFormat format)
Create serial object reader.
CParams & MinRawBufferSize(size_t min_raw_buffer_size)
Single raw data memory buffer size should be at least this big.
virtual bool EndOfData(void)
Check if there is still some meaningful data that can be read; in text streams this function will ski...
CObjectIStreamIterator & operator++(void)
Advance to the next data object.
CObjectIStreamIterator<>::CParams< TRoot > CParams
CIStreamIterator_Base(const CIStreamIterator_Base< TRoot, TObject > &v)
const CObjectIStream & GetObjectIStream(void) const
Return the underlying serial object stream.
CObjectIStreamIterator(const CObjectIStreamIterator &)
queue< CRef< TRoot > > TObjectsQueue
CObjectIStreamAsyncIterator(const CObjectIStreamAsyncIterator &)
input_iterator_tag iterator_category
function< TObjectsQueue(CRef< CByteSource >, ESerialDataFormat, const CParams &, TObjectsQueue &&)> FParserFunction
TObjectPtr GetObjectPtr(void) const
Get pointer to object.
bool operator==(const CObjectIStreamIterator &) const
CObjectIStreamAsyncIterator & operator++(void)
Advance to the next data object.
CObjectInfo GetMember(void) const
Get class member data.
CObjectIStreamIterator<>::FMemberFilter< TR > FMemberFilter
ptrdiff_t difference_type
TObjectsQueue m_ObjectsQueue
TObj * operator->()
Return pointer to data object which is currently pointed to by the iterator.
x_CObjectIStreamIteratorHook(typename CObjectIStreamIterator< TR >::CData *pthis)
CObjectIStreamIterator<>::CParams< TObj > CParent
CIStreamObjectIterator(CObjectIStream &in, EOwnership deleteInStream=eNoOwnership)
CChoiceVariant GetCurrentChoiceVariant(void) const
Get data and type information of selected choice variant.
CIStreamIteratorThread_Base< TRoot, TObject > * m_Reader
virtual void ReadObject(CObjectIStream &in, const CObjectInfo &type) override
This method will be called at approriate time when the object of requested type is to be read.
input_iterator_tag iterator_category
~CIStreamObjectIteratorThread(void)
exception_ptr m_ReaderExpt
TTypeInfo GetTypeInfo(void) const
virtual void * Main(void) override
Derived (user-created) class must provide a real thread function.
TObj & operator*()
Return data object which is currently pointed to by the iterator.
CObjectIStreamIterator<>::CParams< TChild > CParams
CObjectIStreamAsyncIterator<>::CParams< TRoot > CParams
CParams & FilterByMember(const string &mem_name, FMemberFilter< TObj > fn, void *extra=nullptr)
Filter by member name.
~CIStreamStdIteratorThread(void)
CIStreamObjectHook(CIStreamIteratorThread_Base< TRoot, TObject > &thr)
CObjectIStreamIterator end(void)
Construct and return end-of-stream iterator.
const CClassTypeInfo * GetClassTypeInfo(void) const
CIStreamStdIterator(CObjectIStream &in, EOwnership deleteInStream=eNoOwnership)
CObjectInfo GetVariant(void) const
Get variant data.
virtual void Process(const TObject &obj) override
This method will be called when the object of the requested class is read.
CObjectIStreamIterator< TR >::CData * m_This
CIStreamObjectIteratorThread(CObjectIStream &in, EOwnership deleteInStream)
TMemberIndex xxx_MemberIndex(const string &mem_name)
bool operator!=(const CObjectIStreamAsyncIterator &) const
virtual void * Main(void)
Derived (user-created) class must provide a real thread function.
virtual void SkipObject(CObjectIStream &in, const CObjectTypeInfo &type) override
CParams & FilterByMember(TMemberIndex index, FMemberFilter< TObj > fn, void *extra=nullptr)
Filter by member index.
FMemberFilter< TObj > m_FnFilter
friend class CObjectIStreamAsyncIterator
TMemberIndex GetVariantIndex(void) const
Get index of the variant in the choice.
futures_queue_t m_FuturesQueue
CParams & MaxTotalRawSize(size_t max_total_raw_size)
Total size of raw data buffers is allowed to grow to this value.
~CIStreamObjectIterator(void)
ptrdiff_t difference_type
bool operator==(const CObjectIStreamAsyncIterator &) const
const TObject * GetObject(void) const
ETypeFamily GetTypeFamily(void) const
Get data type family.
size_t m_MinRawBufferSize
CObjectIStreamAsyncIterator & operator=(const CObjectIStreamAsyncIterator &)
CObjectIStreamIterator(void)=delete
Construct end-of-stream (invalid) iterator.
CIStreamIterator_Base< TRoot, TObject > & operator=(const CIStreamIterator_Base< TRoot, TObject > &v)
enable_if< is_base_of< CSerialObject, TRoot >::value, TTypeInfo >::type xxx_GetTypeInfo(void)
const TObject & operator*(void) const
~CIStreamIterator_Base(void)
TObj & operator*()
Return data object which is currently pointed to by the iterator.
CParams & LaunchPolicy(launch policy)
Parsing thread launch policy.
CParams & FilterByMember(TMemberIndex index, FMemberFilter< TObj > fn, void *extra=nullptr)
Filter by member index.
CObjectIStreamAsyncIterator & begin(void)
Return self.
CIStreamIteratorThread_Base(CObjectIStream &in, EOwnership deleteInStream)
CObjectIStreamAsyncIterator end(void)
Construct and return end-of-stream iterator.
future< TObjectsQueue > future_queue_t
queue< CRef< CByteSource > > m_ReaderData
TObj * operator->()
Return pointer to data object which is currently pointed to by the iterator.
virtual void * Main(void) override
Derived (user-created) class must provide a real thread function.
bool Serial_FilterSkip(CObjectIStream &in, const CObjectTypeInfo &ctype)
CObjectTypeInfo m_ValueType
CObjectIStreamAsyncIterator(void)=delete
Construct end-of-stream (invalid) iterator.
CObjectIStreamAsyncIterator(CObjectIStream &istr, EOwnership own_istr=eNoOwnership, const CParams< TObj > ¶ms=CParams< TObj >())=delete
Construct iterator upon an object serialization stream.
condition_variable m_ReaderCv
CObjectIStreamIterator< TR >::CData * m_This
CParams & MaxParserThreads(unsigned max_parser_threads)
Maximum number of parsing threads.
bool IsValid(const CSeq_point &pt, CScope *scope)
Checks that point >= 0 and point < length of Bioseq.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::streampos CNcbiStreampos
Portable alias for streampos.
static void Exit(void *exit_data)
Cancel current thread.
void Wait(void)
Wait on semaphore.
void Post(unsigned int count=1)
Increment the semaphore by "count".
void Join(void **exit_data=0)
Wait for the thread termination.
const CItemsInfo & GetItems(void) const
ETypeFamily GetTypeFamily(void) const
bool RandomOrder(void) const
void DefaultReadData(CObjectIStream &in, TObjectPtr object) const
bool Implicit(void) const
enum ENcbiOwnership EOwnership
Ownership relations between objects.
enable_if< is_pod< TRoot >::value||is_convertible< TRoot, std::string >::value, TTypeInfo >::type xxx_GetTypeInfo(void)
const GenericPointer< typename T::ValueType > T2 value
#define NCBI_COMPILER_MSVC
Multi-threading – classes, functions, and features.
std::istream & in(std::istream &in_, double &x_)
CRef< CTestThread > thr[k_NumThreadsMax]