示例#1
0
  //-----------------------------------------------------------------------
  int BspProxyImpl::bspSendWrapper(struct lua_State * state){

    int n = lua_gettop(state);
    assert(n == 1);

    BspSend bspSend;

    bspSend.tagSize(LuaUtils::getIntFromTable(state, "tagSize"))
          .nBytes(LuaUtils::getIntFromTable(state, "nBytes"))
          .superstep(LuaUtils::getIntFromTable(state, "superstep"));


    lua_pushstring(state, "payload");
    lua_gettable(state, -2);
    bspSend.writeInMem(lua_tostring(state,-1));
    lua_pop(state, 1);
    
    lua_pushstring(state, "tag");
    lua_gettable(state, -2);
    bspSend.writeTag(lua_tostring(state,-1));
    lua_pop(state, 1);


    BspProxyImpl::singleInstance->bsmpManager_->addSend(bspSend);
    return 0;
  }
示例#2
0
  //-----------------------------------------------------------------------
  void BsmpManager::bspSend(int pid,const void *tag, const void * payload,int payload_bytes){

    assert(0 <= pid < baseProcess_->getTotalNumProcs());

    BspSend bspSend;
    bspSend.nBytes(payload_bytes).superstep(baseProcess_->superstep()).tagSize(currentTagSize_.value());
    bspSend.writeInMem(payload);
    bspSend.writeTag(tag);
    //cerr << "BsmpManager::bspSend->sending message to task: " << pid << endl;
    //bspSend.dump(true);
    if (pid != baseProcess_->getMyPid())
      stubPool_->bspSend(pid, bspSend);
    else
     addSend(bspSend);

  }
示例#3
0
  //--------------------------------------------------------------------------------
  void BspProxyStubPool::bspSend(const int & taskPid, BspSend & bspSend){

    int initialStackSize = lua_gettop(clientSideState);

    lua_getglobal(clientSideState, getTaskId(taskPid).c_str());
    lua_pushstring(clientSideState, "bspSend");
    lua_gettable(clientSideState, -2);
    lua_getglobal(clientSideState, getTaskId(taskPid).c_str());
    lua_newtable(clientSideState);


    LuaUtils::setFieldOnTable(clientSideState, "nBytes", bspSend.nBytes(), -1);
    LuaUtils::setFieldOnTable(clientSideState, "tagSize", bspSend.tagSize(), -1);
    LuaUtils::setFieldOnTable(clientSideState, "superstep", bspSend.superstep(), -1);
    lua_pushstring(clientSideState, "payload");
    const char * payload = (char *) bspSend.payload();
    lua_pushlstring(clientSideState, payload, bspSend.nBytes());
    lua_settable(clientSideState, -3);
    lua_pushstring(clientSideState, "tag");
    const char * tag = (char *) bspSend.tag();
    lua_pushlstring(clientSideState, tag, bspSend.tagSize());
    lua_settable(clientSideState, -3);




    if (lua_pcall(clientSideState, 2, 0, 0) != 0){
      cerr << "[ERROR] BspProxyStubPool::bspSend->Lua error: "
           << lua_tostring(clientSideState, -1) << endl;
      lua_pop(clientSideState, 1);
    }

    lua_pop(clientSideState, 1);//removes proxy from stack
    assert(initialStackSize == lua_gettop(clientSideState));

  }