示例#1
0
 void ParameterLoaderBase::StartThread()
 {
     DataBlockBase* data_block;
    
     while (data_queue_.Pop(data_block))
     {
         if (!Multiverso::is_pipeline_)
         {
             Multiverso::pipeline_barrier_->Wait();
         }
         if (data_block->Type() != DataBlockType::BeginClock
             && data_block->Type() != DataBlockType::EndClock) // skip Clock
         {
             BeginIteration();
             requests_.clear();
             // Parse data block
             ParseAndRequest(data_block);
             ProcessRequest();
             EndIteration();
         }
         if (!Multiverso::is_pipeline_)
         {
             Multiverso::pipeline_barrier_->Wait();
         }
     }
     if (!Multiverso::is_pipeline_)
     {
         Multiverso::pipeline_barrier_->Wait();
     }
 }
static void Iterate_all_files(benchmark::State& state) {
  std::unique_ptr<TemporaryFile> temp_file(CreateZip());
  ZipArchiveHandle handle;
  void* iteration_cookie;
  ZipEntry data;
  ZipString name;

  while (state.KeepRunning()) {
    OpenArchive(temp_file->path, &handle);
    StartIteration(handle, &iteration_cookie);
    while (Next(iteration_cookie, &data, &name) == 0) {
    }
    EndIteration(iteration_cookie);
    CloseArchive(handle);
  }
}
示例#3
0
static void ProcessAll(ZipArchiveHandle zah) {
  MaybeShowHeader();

  // libziparchive iteration order doesn't match the central directory.
  // We could sort, but that would cost extra and wouldn't match either.
  void* cookie;
  int err = StartIteration(zah, &cookie);
  if (err != 0) {
    error(1, 0, "couldn't iterate %s: %s", archive_name, ErrorCodeString(err));
  }

  ZipEntry entry;
  ZipString string;
  while ((err = Next(cookie, &entry, &string)) >= 0) {
    std::string name(string.name, string.name + string.name_length);
    if (ShouldInclude(name)) ProcessOne(zah, entry, name);
  }

  if (err < -1) error(1, 0, "failed iterating %s: %s", archive_name, ErrorCodeString(err));
  EndIteration(cookie);

  MaybeShowFooter();
}
 ~IterationHandle() {
   EndIteration(cookie_);
 }
示例#5
0
bool CScriptTable::MoveNext( Iterator &iter )
{
    if (!iter.internal.nStackMarker1)
        return false;

    int nTop;
    if(iter.internal.nStackMarker2)
        nTop = iter.internal.nStackMarker2 - 1;	// already traversing the prototype table
    else
        nTop = iter.internal.nStackMarker1 - 1;	// still traversing our own table

    //leave only the index into the stack
    while((lua_gettop(L)-(nTop+1))>1)
    {
        lua_pop(L,1);
    }
    bool bResult = lua_next(L, nTop+1) != 0;
    if (bResult)
    {
        iter.value.Clear();
        bResult = m_pSS->PopAny( iter.value );
        // Get current key.
        m_pSS->ToAny( iter.key, -1 );
        if (lua_type(L,-1) == LUA_TSTRING)
        {
            // String key.
            iter.sKey = (const char*)lua_tostring(L,-1);
            iter.nKey = -1;
        }
        else if(lua_type(L,-1) == LUA_TNUMBER)
        {
            // Number key.
            iter.sKey = NULL;
            iter.nKey = (int)lua_tonumber(L, -1);
        }
        else
        {
            iter.sKey = 0;
            iter.nKey = -1;
        }
    }
    if (!bResult)
    {
        if(iter.internal.nStackMarker1 && !iter.internal.nStackMarker2)
        {
            // just finished traversing our own table
            // => now see if we have a prototype table attached by inspecting our potential metatable
            // => if we don't have a metatable, or have a metatable but no prototype table attached, finish the whole iteration

            if(iter.internal.resolvePrototypeTableAsWell)
            {
                if(lua_getmetatable(L, -1))
                {
                    // yep, we have a metatable
                    lua_pushstring(L, "__index");
                    lua_rawget(L, -2);
                    if(lua_type(L, -1) == LUA_TTABLE)
                    {
                        // yep, the metatable provides us with the prototype table
                        iter.internal.nStackMarker2 = lua_gettop(L);
                        lua_pushnil(L);
                        return MoveNext(iter);
                    }
                }
            }
        }

        EndIteration(iter);
    }
    return bResult;
}