當前位置: 首頁>>代碼示例>>C++>>正文


C++ GetUID函數代碼示例

本文整理匯總了C++中GetUID函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetUID函數的具體用法?C++ GetUID怎麽用?C++ GetUID使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetUID函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: CheckReceiveThreads

	// This function should be only ran when the temporary buffer size is not 0 (otherwise, data is copied directly to the threads)
	bool CheckReceiveThreads()
	{
		SortReceiveThreads();

		bool wokeThreads = false;
		bool freedSpace = false;
		while (!receiveWaitingThreads.empty() && GetUsedSize() > 0)
		{
			MsgPipeWaitingThread *thread = &receiveWaitingThreads.front();
			// Receive as much as possible, even if it's not enough to wake up.
			u32 bytesToSend = std::min(thread->freeSize, GetUsedSize());

			thread->WriteBuffer(Memory::GetPointer(buffer), bytesToSend);
			// Put the unused data at the start of the buffer.
			nmp.freeSize += bytesToSend;
			memmove(Memory::GetPointer(buffer), Memory::GetPointer(buffer) + bytesToSend, GetUsedSize());
			freedSpace = true;

			if (thread->waitMode == SCE_KERNEL_MPW_ASAP || thread->freeSize == 0)
			{
				thread->Complete(GetUID(), 0);
				receiveWaitingThreads.erase(receiveWaitingThreads.begin());
				wokeThreads = true;
				thread = NULL;
			}
			// Stop at the first that can't wake up.
			else
				break;
		}

		if (freedSpace)
			wokeThreads |= CheckSendThreads();

		return wokeThreads;
	}
開發者ID:PewnyPL,項目名稱:ppsspp,代碼行數:36,代碼來源:sceKernelMsgPipe.cpp

示例2: CheckSendThreads

	bool CheckSendThreads()
	{
		SortSendThreads();

		bool wokeThreads = false;
		bool filledSpace = false;
		while (!sendWaitingThreads.empty() && nmp.freeSize > 0)
		{
			MsgPipeWaitingThread *thread = &sendWaitingThreads.front();
			u32 bytesToSend = std::min(thread->freeSize, (u32) nmp.freeSize);

			thread->ReadBuffer(Memory::GetPointer(buffer + GetUsedSize()), bytesToSend);
			nmp.freeSize -= bytesToSend;
			filledSpace = true;

			if (thread->waitMode == SCE_KERNEL_MPW_ASAP || thread->freeSize == 0)
			{
				thread->Complete(GetUID(), 0);
				sendWaitingThreads.erase(sendWaitingThreads.begin());
				wokeThreads = true;
				thread = NULL;
			}
			// Unlike receives, we don't do partial sends.  Stop at first blocked thread.
			else
				break;
		}

		if (filledSpace)
			wokeThreads |= CheckReceiveThreads();

		return wokeThreads;
	}
開發者ID:PewnyPL,項目名稱:ppsspp,代碼行數:32,代碼來源:sceKernelMsgPipe.cpp

示例3: jack_shmalloc

/* allocate a POSIX shared memory segment */
int
jack_shmalloc (const char *shm_name, jack_shmsize_t size, jack_shm_info_t* si)
{
	jack_shm_registry_t* registry;
	int shm_fd;
	int rc = -1;
	char name[SHM_NAME_MAX+1];

	if (jack_shm_lock_registry () < 0) {
        jack_error ("jack_shm_lock_registry fails...");
        return -1;
    }

	if ((registry = jack_get_free_shm_info ()) == NULL) {
		jack_error ("shm registry full");
		goto unlock;
	}

	/* On Mac OS X, the maximum length of a shared memory segment
	 * name is SHM_NAME_MAX (instead of NAME_MAX or PATH_MAX as
	 * defined by the standard).  Unfortunately, Apple sets this
	 * value so small (about 31 bytes) that it is useless for
	 * actual names.  So, we construct a short name from the
	 * registry index for uniqueness and ignore the shm_name
	 * parameter.  Bah!
	 */
	snprintf (name, sizeof (name), "/jack-%d-%d", GetUID(), registry->index);

	if (strlen (name) >= sizeof (registry->id)) {
		jack_error ("shm segment name too long %s", name);
		goto unlock;
	}

	if ((shm_fd = shm_open (name, O_RDWR|O_CREAT, 0666)) < 0) {
		jack_error ("Cannot create shm segment %s (%s)",
			    name, strerror (errno));
		goto unlock;
	}

	if (ftruncate (shm_fd, size) < 0) {
		jack_error ("Cannot set size of engine shm "
			    "registry 0 (%s)",
			    strerror (errno));
		close (shm_fd);
		goto unlock;
	}

	close (shm_fd);
	registry->size = size;
	strncpy (registry->id, name, sizeof (registry->id));
	registry->allocator = GetPID();
	si->index = registry->index;
	si->ptr.attached_at = MAP_FAILED;	/* not attached */
	rc = 0;				/* success */

 unlock:
	jack_shm_unlock_registry ();
	return rc;
}
開發者ID:AndrewCooper,項目名稱:jack2,代碼行數:60,代碼來源:shm.c

示例4: getNormalOfControlSurfaceDevice

PNamedShape CCPACSControlSurfaceDevice::getFlapShape()
{
    PNamedShape loft =  outerShape.GetLoft(
                _segment->GetWing().GetWingCleanShape(),
                getNormalOfControlSurfaceDevice());
    loft->SetName(GetUID().c_str());
    return loft;
}
開發者ID:DLR-SC,項目名稱:tigl,代碼行數:8,代碼來源:CCPACSControlSurfaceDevice.cpp

示例5: SortThreads

	void SortThreads(std::vector<MsgPipeWaitingThread> &waitingThreads, bool usePrio)
	{
		// Clean up any not waiting at the same time.
		HLEKernel::CleanupWaitingThreads(WAITTYPE_MSGPIPE, GetUID(), waitingThreads);

		if (usePrio)
			std::stable_sort(waitingThreads.begin(), waitingThreads.end(), __KernelMsgPipeThreadSortPriority);
	}
開發者ID:libretro,項目名稱:PSP1,代碼行數:8,代碼來源:sceKernelMsgPipe.cpp

示例6: ADDTOCALLSTACK

void CItemSpawn::AddObj(CGrayUID uid)
{
	ADDTOCALLSTACK("CitemSpawn:AddObj");
	// NOTE: This function is also called when loading spawn items
	// on server startup. In this case, some objs UID still invalid
	// (not loaded yet) so just proceed without any checks.

	bool bIsSpawnChar = IsType(IT_SPAWN_CHAR);
	if ( !g_Serv.IsLoading() )
	{
		if ( !uid.IsValidUID() )
			return;

		if ( bIsSpawnChar )				// IT_SPAWN_CHAR can only spawn NPCs
		{
			CChar *pChar = uid.CharFind();
			if ( !pChar || !pChar->m_pNPC )
				return;
		}
		else if ( !uid.ItemFind() )		// IT_SPAWN_ITEM can only spawn items
			return;

		CItemSpawn *pPrevSpawn = static_cast<CItemSpawn*>(uid.ObjFind()->m_uidSpawnItem.ItemFind());
		if ( pPrevSpawn )
		{
			if ( pPrevSpawn == this )		// obj already linked to this spawn
				return;
			pPrevSpawn->DelObj(uid);		// obj linked to other spawn, remove the link before proceed
		}
	}

	BYTE iMax = maximum(GetAmount(), 1);
	for (BYTE i = 0; i < iMax; i++ )
	{
		if ( !m_obj[i].IsValidUID() )
		{
			m_obj[i] = uid;
			m_currentSpawned++;

			// objects are linked to the spawn at each server start
			if ( !g_Serv.IsLoading() )
			{
				uid.ObjFind()->m_uidSpawnItem = GetUID();
				if ( bIsSpawnChar )
				{
					CChar *pChar = uid.CharFind();
					ASSERT(pChar->m_pNPC);
					pChar->StatFlag_Set(STATF_Spawned);
					pChar->m_ptHome = GetTopPoint();
					pChar->m_pNPC->m_Home_Dist_Wander = static_cast<WORD>(m_itSpawnChar.m_DistMax);
				}
			}
			break;
		}
	}
	if ( !g_Serv.IsLoading() )
		ResendTooltip();
}
開發者ID:DarkLotus,項目名稱:Source,代碼行數:58,代碼來源:CItemSpawn.cpp

示例7: SetDirection

void ZActor::Attack_Range(rvector& dir)
{
	m_Animation.Input(ZA_INPUT_ATTACK_RANGE);

	SetDirection(dir);
	rvector pos;
	pos = m_Position + rvector(0, 0, 100);
	ZPostNPCRangeShot(GetUID(), g_pGame->GetTime(), pos, pos + 10000.f*dir, MMCIP_PRIMARY);
}
開發者ID:Asunaya,項目名稱:RefinedGunz,代碼行數:9,代碼來源:ZActor.cpp

示例8: LOG_DEBUG

int       Session::Kick(int reason)
{
    if(GetState() == Session::PLAYER_STATE_KICKING )
    {
        return -1;
    }
    LOG_DEBUG("kick uid = %lu reason = %u [maybe todo notify reason]",GetUID(),reason);
    if(player)
    {
        player->Detach();
    }
    sessionMgr->GetLoginLogic().Logout(sessionMgr->GetSession(GetUID()));
    //-----------------------------------------------------------------
    ResponseClient(gate::GateSSMsg::EVENT_CLOSE,
                   gate::GateSSMsg::CONNECTION_CLOSE_BY_DEFAULT); 
    SetState(Session::PLAYER_STATE_KICKING);
    return 0;
}
開發者ID:jj4jj,項目名稱:playground,代碼行數:18,代碼來源:Session.cpp

示例9: LOG

PNamedShape CTiglAbstractGeometricComponent::GetLoft(void)
{
    if (!(loft)) {
#ifdef DEBUG
        LOG(INFO) << "Building loft " << GetUID();
#endif
        loft = BuildLoft();
    }
    return loft;
}
開發者ID:hyper123,項目名稱:tigl,代碼行數:10,代碼來源:CTiglAbstractGeometricComponent.cpp

示例10: ASSERT

bool CItemMulti::Multi_IsPartOf( const CItem * pItem ) const
{
	// Assume it is in my area test already.
	// IT_MULTI
	// IT_SHIP
	ASSERT( pItem );
	if ( pItem == this )
		return( true );
	return ( pItem->m_uidLink == GetUID());
}
開發者ID:GenerationOfWorlds,項目名稱:Sphere,代碼行數:10,代碼來源:CItemMulti.cpp

示例11: GetMACAdress

/*
*********************************************************************************************************
*	函 數 名: GetMACAdress
*	功能說明: 獲取設備MAC地址。MAC地址前麵三個地址是IEEE給ST公司分配的數據
*	形    參: 將MAC地址寫入mac指針
*	返 回 值: 無
*********************************************************************************************************
*/
void  GetMACAdress(uint8_t *mac) 
{
	uint8_t uid[12];
	GetUID(uid); 
	mac[0]=MAC0;
	mac[1]=MAC1;
	mac[2]=MAC2;
	mac[3]=uid[0]^uid[3]^uid[6]^uid[9];
	mac[4]=uid[1]^uid[4]^uid[7]^uid[10];
	mac[5]=uid[2]^uid[5]^uid[8]^uid[11];
}   
開發者ID:dasuimao,項目名稱:DTS-2500_HMI0030_BOOT,代碼行數:19,代碼來源:bsp_uid.c

示例12: GetTopSector

void CItem::Spawn_GenerateChar( CResourceDef * pDef )
{
	if ( ! IsTopLevel())
		return;	// creatures can only be top level.
	if ( m_itSpawnChar.m_current >= GetAmount())
		return;
	int iComplexity = GetTopSector()->GetCharComplexity();
	if ( iComplexity > g_Cfg.m_iMaxCharComplexity )
	{
		DEBUG_MSG(( "Spawn uid=0%lx too complex (%d>%d)\n", GetUID(), iComplexity, g_Cfg.m_iMaxCharComplexity ));
		return;
	}

	int iDistMax = m_itSpawnChar.m_DistMax;
	RESOURCE_ID_BASE rid = pDef->GetResourceID();
	if ( rid.GetResType() == RES_SPAWN )
	{
		const CRandGroupDef * pSpawnGroup = STATIC_CAST <const CRandGroupDef *>(pDef);
		ASSERT(pSpawnGroup);
		int i = pSpawnGroup->GetRandMemberIndex();
		if ( i >= 0 )
		{
			rid = pSpawnGroup->GetMemberID(i);
		}
	}
	
	CREID_TYPE id;
	if ( rid.GetResType() == RES_CHARDEF || 
		rid.GetResType() == RES_UNKNOWN )
	{
		id = (CREID_TYPE) rid.GetResIndex();
	}
	else
	{
		return;
	}

	CChar * pChar = CChar::CreateNPC( id );
	if ( pChar == NULL )
		return;
	ASSERT(pChar->m_pNPC);

	m_itSpawnChar.m_current ++;
	pChar->Memory_AddObjTypes( this, MEMORY_ISPAWNED );
	// Move to spot "near" the spawn item.
	pChar->MoveNearObj( this, iDistMax );
	if ( iDistMax )
	{
		pChar->m_ptHome = GetTopPoint();
		pChar->m_pNPC->m_Home_Dist_Wander = iDistMax;
	}
	pChar->Update();
}
開發者ID:GenerationOfWorlds,項目名稱:Sphere,代碼行數:53,代碼來源:CItemSp.cpp

示例13: jack_error

    int Shm::shmalloc (const char * /*shm_name*/, jack_shmsize_t size, jack_shm_info_t* si) {
        jack_shm_registry_t* registry;
        int shm_fd;
        int rc = -1;
        char name[SHM_NAME_MAX+1];
 
        if (shm_lock_registry () < 0) {
           jack_error ("jack_shm_lock_registry fails...");
           return -1;
        }

		sp<IAndroidShm> service = getShmService();
		if(service == NULL){
			rc = errno;
			jack_error("shm service is null");
			goto unlock;
		}
 
        if ((registry = get_free_shm_info ()) == NULL) {
           jack_error ("shm registry full");
           goto unlock;
        }

        snprintf (name, sizeof (name), "/jack-%d-%d", GetUID(), registry->index);
        if (strlen (name) >= sizeof (registry->id)) {
           jack_error ("shm segment name too long %s", name);
           goto unlock;
        }

        if((shm_fd = service->allocShm(size)) < 0) {
           rc = errno;
           jack_error ("Cannot create shm segment %s", name);
           goto unlock;
        }
        
        //close (shm_fd);
        registry->size = size;
        strncpy (registry->id, name, sizeof (registry->id) - 1);
        registry->id[sizeof (registry->id) - 1] = '\0';
        registry->allocator = GetPID();
        registry->fd = shm_fd;
        si->fd = shm_fd;
        si->index = registry->index;
        si->ptr.attached_at = MAP_FAILED;  /* not attached */
        rc = 0;  /* success */
        
        jack_d ("[APA] jack_shmalloc : ok ");

unlock:
        shm_unlock_registry ();
        return rc;
    }
開發者ID:jackaudio,項目名稱:jack2,代碼行數:52,代碼來源:Shm.cpp

示例14: jack_set_server_prefix

/* set a unique per-user, per-server shm prefix string
 *
 * According to the POSIX standard:
 *
 *   "The name argument conforms to the construction rules for a
 *   pathname. If name begins with the slash character, then processes
 *   calling shm_open() with the same value of name refer to the same
 *   shared memory object, as long as that name has not been
 *   removed. If name does not begin with the slash character, the
 *   effect is implementation-defined. The interpretation of slash
 *   characters other than the leading slash character in name is
 *   implementation-defined."
 *
 * Since the Linux implementation does not allow slashes *within* the
 * name, in the interest of portability we use colons instead.
 */
static void
jack_set_server_prefix (const char *server_name)
{
#ifdef WIN32
    char buffer[UNLEN+1]={0};
    DWORD len = UNLEN+1;
    GetUserName(buffer, &len);
    snprintf (jack_shm_server_prefix, sizeof (jack_shm_server_prefix),
		  "jack-%s:%s:", buffer, server_name);
#else
    snprintf (jack_shm_server_prefix, sizeof (jack_shm_server_prefix),
		  "jack-%d:%s:", GetUID(), server_name);
#endif
}
開發者ID:AndrewCooper,項目名稱:jack2,代碼行數:30,代碼來源:shm.c

示例15: GetConfiguration

// get short name for loft
std::string CCPACSFuselage::GetShortShapeName ()
{
    unsigned int findex = 0;
    for (int i = 1; i <= GetConfiguration().GetFuselageCount(); ++i) {
        tigl::CCPACSFuselage& f = GetConfiguration().GetFuselage(i);
        if (GetUID() == f.GetUID()) {
            findex = i;
            std::stringstream shortName;
            shortName << "F" << findex;
            return shortName.str();
        }
    }
    return "UNKNOWN";
}
開發者ID:gstariarch,項目名稱:tigl,代碼行數:15,代碼來源:CCPACSFuselage.cpp


注:本文中的GetUID函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。