本文整理汇总了C++中ContextMap类的典型用法代码示例。如果您正苦于以下问题:C++ ContextMap类的具体用法?C++ ContextMap怎么用?C++ ContextMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContextMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(ContextMapTest, VerifyWithThreadsPathological) {
ContextMap<size_t> mp;
// Context collection and exit race threads:
vector<std::shared_ptr<CoreContext>> contexts;
// Exit race controller:
AutoRequired<ExitRaceSignal> signal;
// Create a number of dependent contexts:
for(size_t i = 0; i < 100; i++) {
AutoCreateContext context;
contexts.push_back(context);
// Store a shared pointer
mp.Add(i, context);
// Start the context
context->Initiate();
}
// Set the signal:
signal->Signal();
// Verify that the map empties once our zero-count is hit:
for(size_t i = 0; i < contexts.size(); i++) {
contexts[i]->SignalShutdown(true);
}
// Clear the context collection:
contexts.clear();
EXPECT_EQ(0UL, mp.size()) << "Context map did not empty as expected";
}
示例2: GetContext
// Fetches a previously constructed context by name.
Context* GetContext(const String& name)
{
ContextMap::iterator i = contexts.find(name);
if (i == contexts.end())
return NULL;
return (*i).second;
}
示例3: UNREFERENCED_PARAMETER
CQueue::OnCreateFile(
/*[in]*/ IWDFIoQueue* pQueue,
/*[in]*/ IWDFIoRequest* pRequest,
/*[in]*/ IWDFFile* pFileObject
)
{
UNREFERENCED_PARAMETER(pQueue);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_QUEUE, "%!FUNC! Entry");
// This critical section protects the section of code where we
// Create the serializer and results interfaces used in handling I/O messages.
// We only need to create them once, then we hang on to them for the lifetime of this
// queue object.
CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
HRESULT hr = S_OK;
// Create the WPD serializer
if ((hr == S_OK) &&
(m_pWpdSerializer == NULL))
{
hr = CoCreateInstance(CLSID_WpdSerializer,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWpdSerializer,
(VOID**)&m_pWpdSerializer);
CHECK_HR(hr, "Failed to CoCreate CLSID_WpdSerializer");
}
// Create the client context map and associate it with the File Object
// so we can obtain it on a per-client basis.
if (hr == S_OK)
{
ContextMap* pClientContextMap = new ContextMap();
if(pClientContextMap != NULL)
{
hr = pFileObject->AssignContext(this, (void*)pClientContextMap);
CHECK_HR(hr, "Failed to set client context map");
// Release the client context map if we cannot set it
// properly
if(FAILED(hr))
{
pClientContextMap->Release();
pClientContextMap = NULL;
}
}
else
{
hr = E_OUTOFMEMORY;
CHECK_HR(hr, "Failed to create client context map");
}
}
pRequest->Complete(hr);
return;
}
示例4: releaseContext
void KJavaServerMaintainer::releaseContext(QObject *w, const QString &doc)
{
ContextMap::iterator it = m_contextmap.find(qMakePair(w, doc));
if(it != m_contextmap.end() && --(*it).second <= 0)
{
kdDebug(6100) << "KJavaServerMaintainer::releaseContext" << endl;
(*it).first->deleteLater();
m_contextmap.remove(it);
}
}
示例5: retrace_glXDestroyContext
static void retrace_glXDestroyContext(trace::Call &call) {
ContextMap::iterator it;
it = context_map.find(call.arg(1).toUIntPtr());
if (it == context_map.end()) {
return;
}
it->second->release();
context_map.erase(it);
}
示例6: getContext
static Context *
getContext(unsigned long long context_ptr) {
if (context_ptr == 0) {
return NULL;
}
ContextMap::const_iterator it;
it = context_map.find(context_ptr);
return (it != context_map.end()) ? it->second : NULL;
}
示例7: retrace_wglDeleteContext
static void retrace_wglDeleteContext(trace::Call &call) {
unsigned long long hglrc = call.arg(0).toUIntPtr();
ContextMap::iterator it;
it = context_map.find(hglrc);
if (it == context_map.end()) {
return;
}
it->second->release();
context_map.erase(it);
}
示例8: qMakePair
KJavaAppletContext *KJavaServerMaintainer::getContext(QObject *w, const QString &doc)
{
ContextMap::key_type key = qMakePair(w, doc);
ContextMap::iterator it = m_contextmap.find(key);
if(it != m_contextmap.end())
{
++((*it).second);
return (*it).first;
}
KJavaAppletContext *const context = new KJavaAppletContext();
m_contextmap.insert(key, qMakePair(context, 1));
return context;
}
示例9: getContext
static Context *
getContext(unsigned long long context_ptr) {
if (context_ptr == 0) {
return NULL;
}
ContextMap::const_iterator it;
it = context_map.find(context_ptr);
if (it == context_map.end()) {
return (context_map[context_ptr] = glretrace::createContext());
}
return it->second;
}
示例10: getContext
static glws::Context *
getContext(unsigned long long context_ptr) {
if (context_ptr == 0) {
return NULL;
}
ContextMap::const_iterator it;
it = context_map.find(context_ptr);
if (it == context_map.end()) {
return (context_map[context_ptr] = ws->createContext(visual, NULL));
}
return it->second;
}
示例11: retrace_eglDestroyContext
static void retrace_eglDestroyContext(trace::Call &call) {
unsigned long long orig_context = call.arg(1).toUIntPtr();
ContextMap::iterator it;
it = context_map.find(orig_context);
if (it != context_map.end()) {
glretrace::Context *currentContext = glretrace::getCurrentContext();
if (it->second != currentContext) {
// TODO: reference count
delete it->second;
}
context_map.erase(it);
}
}
示例12: getContext
static Context *
getContext(unsigned long long context_ptr) {
if (context_ptr == 0) {
return NULL;
}
ContextMap::const_iterator it;
it = context_map.find(context_ptr);
if (it == context_map.end()) {
assert(false);
return NULL;
}
return it->second;
}
示例13:
CQueue::OnCleanup(
IWDFObject* pWdfObject
)
{
// Destroy the client context map
HRESULT hr = S_OK;
ContextMap* pClientContextMap = NULL;
hr = pWdfObject->RetrieveContext((void**)&pClientContextMap);
if((hr == S_OK) && (pClientContextMap != NULL))
{
pClientContextMap->Release();
pClientContextMap = NULL;
}
}
示例14: retrace_CGLDestroyContext
static void retrace_CGLDestroyContext(trace::Call &call) {
if (call.ret->toUInt() != kCGLNoError) {
return;
}
unsigned long long ctx = call.arg(0).toUIntPtr();
ContextMap::iterator it;
it = context_map.find(ctx);
if (it == context_map.end()) {
return;
}
delete it->second;
context_map.erase(it);
}
示例15: TraceEvents
CQueue::OnCleanup(
IWDFObject* pWdfObject
)
{
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_QUEUE, "%!FUNC! Entry");
// Destroy the client context map
HRESULT hr = S_OK;
ContextMap* pClientContextMap = NULL;
hr = pWdfObject->RetrieveContext((void**)&pClientContextMap);
if((hr == S_OK) && (pClientContextMap != NULL))
{
pClientContextMap->Release();
pClientContextMap = NULL;
}
}