本文整理汇总了C++中utArray::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ utArray::erase方法的具体用法?C++ utArray::erase怎么用?C++ utArray::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utArray
的用法示例。
在下文中一共展示了utArray::erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loom_asset_pump
void loom_asset_pump()
{
// Currently we only want to do this on the main thread so piggy back on the
// native delegate sanity check to bail if on secondary thread.
if(platform_getCurrentThreadId() != LS::NativeDelegate::smMainThreadID && LS::NativeDelegate::smMainThreadID != 0xBAADF00D)
return;
loom_mutex_lock(gAssetLock);
// Talk to the asset server.
loom_asset_serviceServer();
// For now just blast all the data from each file into the asset.
while(gAssetLoadQueue.size())
{
loom_asset_t *asset = gAssetLoadQueue.front();
// Figure out the type from the path.
utString path = asset->name;
int type = loom_asset_recognizeAssetTypeFromPath(path);
if(type == 0)
{
lmLog(gAssetLogGroup, "Could not infer type of resource '%s', skipping it...", path.c_str());
asset->state = loom_asset_t::Unloaded;
gAssetLoadQueue.erase((UTsize)0, true);
continue;
}
// Open the file.
void *ptr;
long size;
if(!platform_mapFile(asset->name.c_str(), &ptr, &size))
{
lmAssert(false, "Could not open file '%s'.", asset->name.c_str());
}
// Deserialize it.
LoomAssetCleanupCallback dtor = NULL;
void *assetBits = loom_asset_deserializeAsset(path, type, size, ptr, &dtor);
// Close the file.
platform_unmapFile(ptr);
// Instate the asset.
asset->instate(type, assetBits, dtor);
// Done! Update queue.
gAssetLoadQueue.erase((UTsize)0, true);
}
loom_mutex_unlock(gAssetLock);
}
示例2: socketListeningThread
// Entry point for the socket thread. Listen for connections and incoming data,
// and route it to the protocol handlers.
static int socketListeningThread(void *payload)
{
// Listen for incoming connections.
int listenPort = 12340;
gListenSocket = (loom_socketId_t)-1;
for ( ; ; )
{
gListenSocket = loom_net_listenTCPSocket(listenPort);
if (gListenSocket != (loom_socketId_t)-1)
{
break;
}
lmLogWarn(gAssetAgentLogGroup, " - Failed to acquire port %d, trying port %d", listenPort, listenPort + 1);
listenPort++;
}
lmLog(gAssetAgentLogGroup, "Listening on port %d", listenPort);
while (loom_socketId_t acceptedSocket = loom_net_acceptTCPSocket(gListenSocket))
{
// Check to see if we got anybody...
if (!acceptedSocket || ((int)(long)acceptedSocket == -1))
{
// Process the connections.
loom_mutex_lock(gActiveSocketsMutex);
for (UTsize i = 0; i < gActiveHandlers.size(); i++)
{
AssetProtocolHandler* aph = gActiveHandlers[i];
aph->process();
// Check for ping timeout
int msSincePing = loom_readTimer(aph->lastActiveTime);
if (msSincePing > socketPingTimeoutMs)
{
gActiveHandlers.erase(i);
i--;
lmLog(gAssetAgentLogGroup, "Client timed out (%x)", aph->socket);
loom_net_closeTCPSocket(aph->socket);
lmDelete(NULL, aph);
}
}
loom_mutex_unlock(gActiveSocketsMutex);
loom_thread_sleep(10);
continue;
}
lmLog(gAssetAgentLogGroup, "Client connected (%x)", acceptedSocket);
loom_mutex_lock(gActiveSocketsMutex);
gActiveHandlers.push_back(lmNew(NULL) AssetProtocolHandler(acceptedSocket));
AssetProtocolHandler *handler = gActiveHandlers.back();
handler->registerListener(lmNew(NULL) TelemetryListener());
if (TelemetryServer::isRunning()) handler->sendCommand("telemetryEnable");
// Send it all of our files.
// postAllFiles(gActiveHandlers[gActiveHandlers.size()-1]->getId());
loom_mutex_unlock(gActiveSocketsMutex);
}
return 0;
}
示例3: processFileEntryDeltas
//.........这里部分代码省略.........
// Only consider pending items that have aged out.
FileModificationNote& fmn = gPendingModifications.at(i);
if (curTime - fmn.lastSeenTime < settleTimeMs)
{
continue;
}
totalPendingTransfers++;
}
bool didWeNotifyUserAboutPending = false;
for (UTsize i = 0; i < gPendingModifications.size(); i++)
{
// Only consider pending items that have aged out.
FileModificationNote& fmn = gPendingModifications.at(i);
if (curTime - fmn.lastSeenTime < settleTimeMs)
{
continue;
}
// Make the path canonical.
utString filename = fmn.path;
char canonicalFile[MAXPATHLEN];
makeAssetPathCanonical(filename.c_str(), canonicalFile);
// Note: we don't deal with deleted files properly (by uploading new state) because realpath
// only works right when the file exists. So we just skip doing anything about it.
// Note we are using gActiveHandlers.size() outside of a lock, but this is ok as it's a word.
if ((strstr(canonicalFile, ".loom") || strstr(canonicalFile, ".ls")) && (gActiveHandlers.size() > 0))
{
lmLog(gAssetAgentLogGroup, "Changed '%s'", canonicalFile);
}
if (canonicalFile[0] == 0)
{
lmLog(gAssetAgentLogGroup, " o Ignoring file missing from the asset folder!");
// Remove from the pending list.
gPendingModifications.erase(i);
i--;
continue;
}
// Queue the callback.
enqueueFileChangeCallback(canonicalFile);
// Map the file.
void *fileBits = NULL;
long fileBitsLength = 0;
if (!platform_mapFile(canonicalFile, &fileBits, &fileBitsLength))
{
lmLog(gAssetAgentLogGroup, " o Skipping due to file failing to map.");
continue;
}
// Loop over the active sockets.
loom_mutex_lock(gActiveSocketsMutex);
// Blast it out to all clients.
for (UTsize j = 0; j < gActiveHandlers.size(); j++)
{
// If it's for a specific client then only send to that client.
if ((fmn.onlyForClient != -1) && (fmn.onlyForClient != gActiveHandlers[j]->getId()))
{
continue;
}
gActiveHandlers[j]->sendFile(canonicalFile, fileBits, fileBitsLength, totalPendingTransfers);
// If it has been more than a second, note that we are still working.
const int remainingTransferCount = (totalPendingTransfers * gActiveHandlers.size()) - j;
if (((platform_getMilliseconds() - transferStartTime) > 2000) && (remainingTransferCount > 1))
{
transferStartTime = platform_getMilliseconds();
lmLog(gAssetAgentLogGroup, "Still transferring files. %d to go!", remainingTransferCount - 1);
didWeNotifyUserAboutPending = true;
}
}
loom_mutex_unlock(gActiveSocketsMutex);
totalPendingTransfers--;
// Unmap the file.
platform_unmapFile(fileBits);
// Remove from the pending list.
gPendingModifications.erase(i);
i--;
}
loom_mutex_unlock(gFileScannerLock);
if (didWeNotifyUserAboutPending)
{
lmLog(gAssetAgentLogGroup, "Done transferring files!");
}
}