本文整理汇总了C++中MethodInfo::Invoke方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodInfo::Invoke方法的具体用法?C++ MethodInfo::Invoke怎么用?C++ MethodInfo::Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodInfo
的用法示例。
在下文中一共展示了MethodInfo::Invoke方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunPump
void nsToolkit::RunPump(void* arg)
{
int32 code;
char portname[64];
ThreadInterfaceData id;
#ifdef DEBUG
printf("TK-RunPump\n");
#endif
ThreadInitInfo *info = (ThreadInitInfo*)arg;
PR_EnterMonitor(info->monitor);
gThreadState = PR_TRUE;
PR_Notify(info->monitor);
PR_ExitMonitor(info->monitor);
delete info;
// system wide unique names
PR_snprintf(portname, sizeof(portname), "event%lx",
(long unsigned) PR_GetCurrentThread());
port_id event = create_port(200, portname);
while(read_port_etc(event, &code, &id, sizeof(id), B_TIMEOUT, 1000) >= 0)
{
MethodInfo *mInfo = (MethodInfo *)id.data;
mInfo->Invoke();
if(id.waitingThread != 0)
resume_thread(id.waitingThread);
delete mInfo;
}
}
示例2: RunPump
void nsToolkit::RunPump(void* arg)
{
int32 code;
char portname[64];
ThreadInterfaceData id;
ThreadInitInfo *info = (ThreadInitInfo*)arg;
PR_EnterMonitor(info->monitor);
gThreadState = PR_TRUE;
PR_Notify(info->monitor);
PR_ExitMonitor(info->monitor);
delete info;
// system wide unique names
PR_snprintf(portname, sizeof(portname), "event%lx",
(long unsigned) PR_GetCurrentThread());
port_id event = create_port(100, portname);
while(read_port(event, &code, &id, sizeof(id)) >= 0)
{
switch(code)
{
case WM_CALLMETHOD :
{
MethodInfo *mInfo = (MethodInfo *)id.data;
mInfo->Invoke();
if(id.waitingThread != 0)
resume_thread(id.waitingThread);
delete mInfo;
}
break;
case 'natv' : // native queue PLEvent
{
PREventQueue *queue = (PREventQueue *)id.data;
PR_ProcessPendingEvents(queue);
}
break;
default :
printf("nsToolkit::RunPump - UNKNOWN EVENT\n");
break;
}
}
}
示例3: RunPump
void nsToolkit::RunPump(void* arg)
{
int32 code;
char portname[64];
ThreadInterfaceData id;
ThreadInitInfo *info = (ThreadInitInfo*)arg;
PR_EnterMonitor(info->monitor);
gThreadState = PR_TRUE;
PR_Notify(info->monitor);
PR_ExitMonitor(info->monitor);
delete info;
// system wide unique names
int32 cookie = 0;
image_info iinfo;
char *leaf = NULL;
do {
if (get_next_image_info(0, &cookie, &iinfo) == B_OK &&
strlen(iinfo.name) > 0 &&
(leaf = strrchr(iinfo.name, '/')) != NULL)
{
leaf++;
PR_snprintf(portname, sizeof(portname), "event%lx",
(long unsigned) find_thread(leaf));
}
else
{
PR_snprintf(portname, sizeof(portname), "event%lx",
(long unsigned) find_thread(0));
}
} while(iinfo.type != B_APP_IMAGE);
port_id event = create_port(200, portname);
while(read_port(event, &code, &id, sizeof(id)) >= 0)
{
switch(code)
{
case WM_CALLMETHOD :
{
MethodInfo *mInfo = (MethodInfo *)id.data;
mInfo->Invoke();
if(id.waitingThread != 0)
resume_thread(id.waitingThread);
delete mInfo;
}
break;
case 'natv' : // native queue PLEvent
{
PREventQueue *queue = (PREventQueue *)id.data;
PR_ProcessPendingEvents(queue);
}
break;
default :
printf("nsToolkit::RunPump - UNKNOWN EVENT\n");
break;
}
}
}
示例4: ProcessRequest
//.........这里部分代码省略.........
}
// --------------------------------------------------------------
// Allow a more REST like calling convention. If the Method
// Name isn't found, search for one with the request method
// appended to the name ( "Get" or "Put" for POST)
// --------------------------------------------------------------
QString sMethodName = pRequest->m_sMethod;
bool bMethodFound = false;
if (m_Methods.contains(sMethodName))
bMethodFound = true;
else
{
switch( pRequest->m_eType )
{
case RequestTypeHead:
case RequestTypeGet :
sMethodName = "Get" + sMethodName;
break;
case RequestTypePost:
sMethodName = "Put" + sMethodName;
break;
case RequestTypeUnknown:
case RequestTypeOptions:
case RequestTypeMSearch:
case RequestTypeSubscribe:
case RequestTypeUnsubscribe:
case RequestTypeNotify:
case RequestTypeResponse:
// silence compiler
break;
}
if (m_Methods.contains(sMethodName))
bMethodFound = true;
}
if (bMethodFound)
{
MethodInfo oInfo = m_Methods.value( sMethodName );
if (( pRequest->m_eType & oInfo.m_eRequestType ) != 0)
{
// ------------------------------------------------------
// Create new Instance of the Service Class so
// it's guaranteed to be on the same thread
// since we are making direct calls into it.
// ------------------------------------------------------
pService =
qobject_cast<Service*>(m_oMetaObject.newInstance());
QVariant vResult = oInfo.Invoke(pService,
pRequest->m_mapParams);
bHandled = FormatResponse( pRequest, vResult );
}
}
if (!bHandled)
UPnp::FormatErrorResponse( pRequest, UPnPResult_InvalidAction );
}
}
catch (HttpRedirectException &ex)
{
UPnp::FormatRedirectResponse( pRequest, ex.hostName );
bHandled = true;
}
catch (HttpException &ex)
{
LOG(VB_GENERAL, LOG_ERR, ex.msg);
UPnp::FormatErrorResponse( pRequest, UPnPResult_ActionFailed, ex.msg );
bHandled = true;
}
catch (QString &sMsg)
{
LOG(VB_GENERAL, LOG_ERR, sMsg);
UPnp::FormatErrorResponse( pRequest, UPnPResult_ActionFailed, sMsg );
bHandled = true;
}
catch ( ...)
{
QString sMsg( "ServiceHost::ProcessRequest - Unexpected Exception" );
LOG(VB_GENERAL, LOG_ERR, sMsg);
UPnp::FormatErrorResponse( pRequest, UPnPResult_ActionFailed, sMsg );
bHandled = true;
}
if (pService != nullptr)
delete pService;
return bHandled;
}