示例#1
0
	void write(iterator rsa, iterator rse)
	{
		lock.lock();
		
		expandBuf(rse-rsa);
		std::copy ( rsa, rse, buf.get() );
		u_int8_t const * sa = buf.get();
		u_int8_t const * se = sa + (rse-rsa);
		
		while ( sa != se )
		{
			ssize_t const wr = ::write(fd,sa,se-sa);
			
			if ( wr <= 0 )
			{
				switch ( errno )
				{
					case EINTR:
						break;
					default:
						std::cerr << "write() failed with error code " << errno << ": " << strerror(errno) << " wr " << wr << std::endl;
						throw std::runtime_error("write() failed.");
						break;
				}
			}
			else
			{
				sa += wr;
			}
		}
		lock.unlock();
	}
示例#2
0
文件: RangeVector.hpp 项目: gt1/REAL
 RangeVector(std::vector < std::pair < std::string, u_int64_t > > const & rranges)
 : ranges(rranges), AB ( fillRange(ranges) ), B ( AB.get() ),
   R(B, ((ranges.at(ranges.size()-1).second+1+63)/64)*64 )
 {
         #if 0
         for ( u_int64_t i = 0; i <= ranges.back().second; ++i )
                 std::cerr << Rank::getBit(B,i) << "(" << R.rank1(i)-1 << ")";
         std::cerr << std::endl;
         #endif
 }
示例#3
0
 void setup(unsigned int npatl)
 {
         if ( npatl > maxpatl )
         {
                 ABstraight = AutoArray<u_int64_t>(RestMatch<sse4>::getRestWords(npatl,seedl));
                 Bstraight = ABstraight.get();
                 ABreverse = AutoArray<u_int64_t>(RestMatch<sse4>::getRestWords(npatl,seedl));
                 Breverse = ABreverse.get();
                 maxpatl = npatl;
         }
         if ( npatl != patl )
         {
                 patl = npatl;
                 numrestwords = RestMatch<sse4>::getRestWords(patl,seedl);
                 fullrestwords = RestMatch<sse4>::getFullRestWords(patl, seedl);
                 fracrestsyms = RestMatch<sse4>::getFracRestSyms(patl, seedl, fullrestwords);
                 straighttextrestoffset = RestMatch<sse4>::getTextRestOffset(patl, seedl, false);
                 reversetextrestoffset = RestMatch<sse4>::getTextRestOffset(patl, seedl, true);
                 straightmatchoffset = RestMatch<sse4>::getMatchOffset(patl, seedl, false);
                 reversematchoffset = RestMatch<sse4>::getMatchOffset(patl, seedl, true);                        
         }
 }
	void get(ReadIterator & source, PlanetNodeStatusMessageData &d)
	{
		get(source,d.m_x);
		get(source,d.m_z);
		get(source,d.m_loaded);

		AutoArray<uint32> temp;
		get(source,temp);
		d.m_servers=temp.get();

		AutoArray<int> temp2;
		get(source,temp2);
		d.m_subscriptionCounts=temp2.get();							
	}
示例#5
0
文件: RangeVector.hpp 项目: gt1/REAL
        static AutoArray<u_int64_t> fillRange(
                std::vector < std::pair < std::string, u_int64_t > > const & ranges
                )
        {
                AutoArray<u_int64_t> AB ( (ranges.at(ranges.size()-1).second+1+63)/64 );

                for ( u_int64_t i = 0; i < (ranges.at(ranges.size()-1).second+1+63)/64; ++i )
                        AB[i] = 0;

                Rank::BitWriter8 W(AB.get());
                
                for ( unsigned int j = 0; j+1 < ranges.size(); ++j )
                {
                        u_int64_t len = ranges[j+1].second-ranges[j].second;
                        W.writeBit(true);
                        for ( u_int64_t i = 1; i < len; ++i )
                                W.writeBit(false);
                }
                W.writeBit(true);
                
                W.flush();
                
                return AB;
        }