int main(){ int i = 100; npp(&i); printf("%d\n",i); printf("--------"); int a = 10,b = 20; swap(&a,&b); printf("a = %d,b = %d\n",a,b); return 0; }
bool TransferServer::enqueue(ConnectionIdentifier clt, Stream& stream) { NetworkPackagePtr npp(new NetworkPackage); if(!npp->decode(stream)) return false; ServiceIdentifier& sid = npp->getSrcIdentifier(); sid.m_appref = clt.m_clientid; m_dispatcherInterface->postMessage(sid, npp->getDstIdentifier(), npp->getUTM(), false); return true; }
osgToy::TetraStrip::TetraStrip() { osg::Vec3Array* vAry = dynamic_cast<osg::Vec3Array*>( getVertexArray() ); osg::Vec3Array* nAry = dynamic_cast<osg::Vec3Array*>( getNormalArray() ); setNormalBinding( osg::Geometry::BIND_PER_VERTEX ); osg::Vec4Array* cAry = dynamic_cast<osg::Vec4Array*>( getColorArray() ); setColorBinding( osg::Geometry::BIND_PER_VERTEX ); osg::Vec3 ppp( 1, 1, 1); osg::Vec4 white(1,1,1,1); osg::Vec3 nnp( -1, -1, 1); osg::Vec4 blue(0,0,1,1); osg::Vec3 pnn( 1, -1, -1); osg::Vec4 red(1,0,0,1); osg::Vec3 npn( -1, 1, -1); osg::Vec4 green(0,1,0,1); osg::Vec3 ppn( 1, 1, -1); osg::Vec4 yellow(1,1,0,1); osg::Vec3 pnp( 1, -1, 1); osg::Vec4 magenta(1,0,1,1); osg::Vec3 nnn( -1, -1, -1); osg::Vec4 black(0,0,0,1); osg::Vec3 npp( -1, 1, 1); osg::Vec4 cyan(0,1,1,1); #if 1 vAry->push_back(ppp); nAry->push_back(ppp); cAry->push_back(white); vAry->push_back(nnp); nAry->push_back(nnp); cAry->push_back(blue); vAry->push_back(pnn); nAry->push_back(pnn); cAry->push_back(red); vAry->push_back(npn); nAry->push_back(npn); cAry->push_back(green); vAry->push_back(ppp); nAry->push_back(ppp); cAry->push_back(white); vAry->push_back(nnp); nAry->push_back(nnp); cAry->push_back(blue); #else vAry->push_back(ppn); nAry->push_back(ppn); cAry->push_back(yellow); vAry->push_back(pnp); nAry->push_back(pnp); cAry->push_back(magenta); vAry->push_back(nnn); nAry->push_back(nnn); cAry->push_back(black); vAry->push_back(npp); nAry->push_back(npp); cAry->push_back(cyan); vAry->push_back(ppn); nAry->push_back(ppn); cAry->push_back(yellow); vAry->push_back(pnp); nAry->push_back(pnp); cAry->push_back(magenta); #endif addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLE_STRIP, 0, vAry->size() ) ); }
bool plNetClientMgr::IHandlePlayerPageMsg(plPlayerPageMsg *playerMsg) { bool result = false; plKey playerKey = playerMsg->fPlayer; int idx; if(playerMsg->fUnload) { if (GetLocalPlayerKey() == playerKey) { fLocalPlayerKey = nil; DebugMsg("Net: Unloading local player %s", playerKey->GetName().c_str()); // notify server - NOTE: he might not still be around to get this... plNetMsgPlayerPage npp (playerKey->GetUoid(), playerMsg->fUnload); npp.SetNetProtocol(kNetProtocolCli2Game); SendMsg(&npp); } else if (IsRemotePlayerKey(playerKey, &idx)) { fRemotePlayerKeys.erase(fRemotePlayerKeys.begin()+idx); // remove key from list DebugMsg("Net: Unloading remote player %s", playerKey->GetName().c_str()); } } else { plSceneObject *playerSO = plSceneObject::ConvertNoRef(playerKey->ObjectIsLoaded()); if (!playerSO) { hsStatusMessageF("Ignoring player page message for non-existant player."); } else if(playerMsg->fPlayer) { if (playerMsg->fLocallyOriginated) { hsAssert(!GetLocalPlayerKey() || GetLocalPlayerKey() == playerKey, "Different local player already loaded"); hsLogEntry(DebugMsg("Adding LOCAL player %s\n", playerKey->GetName().c_str())); playerSO->SetNetGroupConstant(plNetGroup::kNetGroupLocalPlayer); // don't save avatar state permanently on server playerSO->SetSynchFlagsBit(plSynchedObject::kAllStateIsVolatile); const plCoordinateInterface* co = playerSO->GetCoordinateInterface(); if (co) { int i; for(i=0;i<co->GetNumChildren();i++) { if (co->GetChild(i) && co->GetChild(i)->GetOwner()) const_cast<plSceneObject*>(co->GetChild(i)->GetOwner())->SetSynchFlagsBit(plSynchedObject::kAllStateIsVolatile); } } // notify server plNetMsgPlayerPage npp (playerKey->GetUoid(), playerMsg->fUnload); npp.SetNetProtocol(kNetProtocolCli2Game); SendMsg(&npp); } else { hsLogEntry(DebugMsg("Adding REMOTE player %s\n", playerKey->GetName().c_str())); playerSO->SetNetGroupConstant(plNetGroup::kNetGroupRemotePlayer); idx=fTransport.FindMember(playerMsg->fClientID); if( idx != -1 ) { hsAssert(playerKey, "NIL KEY?"); hsAssert(!playerKey->GetName().IsNull(), "UNNAMED KEY"); fTransport.GetMember(idx)->SetAvatarKey(playerKey); } else { hsLogEntry(DebugMsg("Ignoring player page msg (player not found in member list) : %s\n", playerKey->GetName().c_str())); } } hsAssert(IFindModifier(playerSO, CLASS_INDEX_SCOPED(plAvatarSDLModifier)), "avatar missing avatar SDL modifier"); hsAssert(IFindModifier(playerSO, CLASS_INDEX_SCOPED(plClothingSDLModifier)), "avatar missing clothing SDL modifier"); hsAssert(IFindModifier(playerSO, CLASS_INDEX_SCOPED(plAGMasterSDLModifier)), "avatar missing AGMaster SDL modifier"); result = true; } } return result; }
void *producer() { clock_t prod_t1,prod_t2,prod_t3,prod_tf,t1_ovr; int a = 0; int loop_dc = 0; char location; FILE *fp; location = 0; printf("Producer Start\n\n"); while(start == 1) { printf("waiting for recorder to complete file write\n"); t1_ovr = clock(); sem_wait(&wait_read); t_ovr = clock(); if (a%2 == 0) { //t_ovr = clock(); fp = fopen("record0.raw", "rb"); } else if(a%2 == 1) { fp = fopen("record1.raw", "rb"); //exit(1); } a++; while(eof_reached == 0) { sem_wait(&empty); length = fread(buff,sizeof(short),FRM,fp); npp(buff, buff); npp(&(buff[FRAME]), &(buff[FRAME])); npp(&(buff[2 * FRAME]), &(buff[2 * FRAME])); sem_post(&id_analyzer); inner_melp_post_count = inner_melp_post_count + 1; //printf("number %d melp post from producer\n",inner_melp_post_count); if (length < FRM) { count = count + 1; eof_reached = 1; printf("eof reached\n"); length_count = length_count + 1; } //prod_t2 = clock() - prod_t1; //printf ("time in prod_thread is %f secs\n",((float)prod_t2)/CLOCKS_PER_SEC); //exit(1); } //printf("end of File %d\n\n",a); eof_reached = 0; inner_melp_post_count = 0; length_count = 0; fclose(fp); prod_t2 = clock() - t_ovr; printf ("Time in 1 file operation excluding wait for file_read: %f secs\n\n",((float)prod_t2)/CLOCKS_PER_SEC); prod_t3 = clock() - t1_ovr; printf ("Time in 1 file operation including wait for file_read: %f secs\n\n",((float)prod_t3)/CLOCKS_PER_SEC); } printf("PRODUCER end\n\n"); count = 0; //sem_post(&mutx); sem_post(&full); pthread_exit(NULL); }