本文整理汇总了C++中rc::Handle类的典型用法代码示例。如果您正苦于以下问题:C++ Handle类的具体用法?C++ Handle怎么用?C++ Handle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Handle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
ClientWrap::ClientWrap( int compileGuarded )
: m_mutex("Node.js ClientWrap")
{
std::vector<std::string> pluginPaths;
Plug::AppendUserPaths( pluginPaths );
Plug::AppendGlobalPaths( pluginPaths );
CG::CompileOptions compileOptions;
if ( compileGuarded > -1 )
compileOptions.setGuarded( compileGuarded );
else
compileOptions.setGuarded( false );
RC::Handle<IO::Manager> ioManager = IOManager::Create( &ClientWrap::ScheduleAsyncUserCallback, this );
RC::Handle<DG::Context> dgContext = DG::Context::Create( ioManager, pluginPaths, compileOptions, true );
#if defined(FABRIC_MODULE_OPENCL)
OCL::registerTypes( dgContext->getRTManager() );
#endif
Plug::Manager::Instance()->loadBuiltInPlugins( pluginPaths, dgContext->getCGManager(), DG::Context::GetCallbackStruct() );
m_client = Client::Create( dgContext, this );
m_mainThreadTLS = true;
uv_async_init( uv_default_loop(), &m_uvAsync, &ClientWrap::AsyncCallback );
m_uvAsync.data = this;
//// uv_timer_init adds a loop reference. (That is, it calls uv_ref.) This
//// is not the behavior we want in Node. Timers should not increase the
//// ref count of the loop except when active.
//uv_unref( uv_default_loop() );
}
示例2: llvmRelease
void ArrayProducerAdapter::llvmRelease( CG::BasicBlockBuilder &basicBlockBuilder, llvm::Value *rValue ) const
{
RC::Handle<Context> context = basicBlockBuilder.getContext();
std::vector<llvm::Type *> argTypes;
argTypes.push_back( llvmRType( context ) );
llvm::FunctionType *funcType = llvm::FunctionType::get( llvm::Type::getVoidTy( context->getLLVMContext() ), argTypes, false );
llvm::Constant *func = basicBlockBuilder.getModuleBuilder()->getOrInsertFunction( "__"+getCodeName()+"__Release", funcType );
basicBlockBuilder->CreateCall( func, rValue );
}
示例3: executeOneTaskIfPossible_CRITICAL_SECTION
void ThreadPool::executeOneTaskIfPossible_CRITICAL_SECTION()
{
if ( m_tasks.empty() && m_idleTasks.empty() && (!m_isMainThread.get() || m_mainThreadTasks.empty()) )
m_stateCond.wait( m_stateMutex );
else
{
std::vector<Task *> *taskQueue;
if ( m_isMainThread.get() && !m_mainThreadTasks.empty() )
taskQueue = &m_mainThreadTasks;
else if ( !m_tasks.empty() )
taskQueue = &m_tasks;
else taskQueue = &m_idleTasks;
Task *task = taskQueue->back();
size_t index;
bool keep;
task->preExecute_CRITICAL_SECTION( index, keep );
if ( !keep )
taskQueue->pop_back();
m_stateMutex.release();
try
{
task->execute( index );
}
catch ( Exception e )
{
Util::SimpleString prefixedException = "Exception: " + e.getDesc();
RC::Handle<LogCollector> logCollector = task->getLogCollector();
if ( logCollector )
logCollector->add( prefixedException.data(), prefixedException.length() );
}
catch ( ... )
{
static Util::SimpleString const genericException = "Exception (unknown)";
RC::Handle<LogCollector> logCollector = task->getLogCollector();
if ( logCollector )
logCollector->add( genericException.data(), genericException.length() );
}
m_stateMutex.acquire();
task->postExecute_CRITICAL_SECTION();
if ( task->completed_CRITICAL_SECTION() )
{
void (*finishedCallback)( void * ) = task->getFinishedCallback();
if ( finishedCallback )
finishedCallback( task->getFinishedUserdata() );
task->dispose();
// [pzion 20101108] Must wake waiter because they might be
// waiting on the task completion
m_stateCond.broadcast();
}
}
}
示例4: JSONExecProduceAsyncFinishedCallback
void ValueProducerWrapper::JSONExecProduceAsyncFinishedCallback( void *userdata )
{
JSONProduceAsyncUserdata *jsonProduceAsyncUserdata = static_cast<JSONProduceAsyncUserdata *>( userdata );
RC::Handle<ValueProducerWrapper> valueProducerWrapper = jsonProduceAsyncUserdata->valueProducerWrapper;
Util::SimpleString *notifyJSONArg = jsonProduceAsyncUserdata->notifyJSONArg;
delete jsonProduceAsyncUserdata;
valueProducerWrapper->jsonNotify( "produceAsyncFinished", 20, notifyJSONArg );
delete notifyJSONArg;
}
示例5: llvmDefaultAssign
void ArrayProducerAdapter::llvmDefaultAssign( BasicBlockBuilder &basicBlockBuilder, llvm::Value *dstLValue, llvm::Value *srcRValue ) const
{
RC::Handle<Context> context = basicBlockBuilder.getContext();
std::vector<llvm::Type *> argTypes;
argTypes.push_back( llvmRType( context ) );
argTypes.push_back( llvmLType( context ) );
llvm::FunctionType *funcType = llvm::FunctionType::get( llvm::Type::getVoidTy( context->getLLVMContext() ), argTypes, false );
llvm::Constant *func = basicBlockBuilder.getModuleBuilder()->getOrInsertFunction( "__"+getCodeName()+"__DefaultAssign", funcType );
basicBlockBuilder->CreateCall2( func, srcRValue, dstLValue );
}
示例6:
void ArrayProducerAdapter::Produce0( void const *_adapter, void const *arrayProducerRValue, void *dstLValue )
{
MR::ArrayProducer *arrayProducer = *static_cast<MR::ArrayProducer * const *>( arrayProducerRValue );
if ( arrayProducer )
{
RC::Handle<MR::ArrayProducer::ComputeState> computeState = arrayProducer->createComputeState();
size_t count = computeState->getCount();
RC::ConstHandle<RT::VariableArrayDesc> elementVariableArrayDesc = RC::ConstHandle<RT::VariableArrayDesc>::StaticCast( static_cast<ArrayProducerAdapter const *>( _adapter )->m_elementVariableArrayAdapter->getDesc() );
elementVariableArrayDesc->setNumMembers( dstLValue, count );
void *firstMemberData = elementVariableArrayDesc->getMutableMemberData( dstLValue, 0 );
computeState->produce( 0, count, firstMemberData );
}
}
示例7: jg
RC::Handle<ResourceLoadNode> ResourceLoadNode::Create( std::string const &name, RC::Handle<Context> const &context )
{
RC::Handle<ResourceLoadNode> resourceLoadNode = new ResourceLoadNode( name, context );
Util::SimpleString json;
{
JSON::Encoder jg( &json );
resourceLoadNode->jsonDesc( jg );
}
resourceLoadNode->jsonNotifyDelta( json );
return resourceLoadNode;
}
示例8: GetPrototypeException
ArrayOutputOperator::ArrayOutputOperator(
RC::ConstHandle<Executable> const &executable,
RC::ConstHandle<AST::Operator> const &astOperator,
void (*functionPtr)(...)
)
: m_executable( executable )
{
if ( astOperator )
{
RC::Handle<CG::Manager> cgManager = executable->getCGManager();
RC::ConstHandle<AST::ParamVector> params = astOperator->getParams( cgManager );
size_t numParams = params->size();
if ( numParams < 1 || numParams > 4 )
throw GetPrototypeException();
RC::ConstHandle<AST::Param> valueParam = params->get(0);
if ( valueParam->getUsage() != CG::USAGE_LVALUE )
throw GetPrototypeException();
RC::ConstHandle<RT::Desc> valueDesc = valueParam->getAdapter( cgManager )->getDesc();
RC::ConstHandle<RT::Desc> sharedDesc;
if ( numParams >= 2 )
{
RC::ConstHandle<AST::Param> indexParam = params->get(1);
if ( indexParam->getUsage() != CG::USAGE_RVALUE
|| !indexParam->getAdapter( cgManager )->isEquivalentTo( cgManager->getSizeAdapter() )
)
throw GetPrototypeException();
if ( numParams >= 3 )
{
RC::ConstHandle<AST::Param> countParam = params->get(2);
if ( countParam->getUsage() != CG::USAGE_RVALUE
|| !countParam->getAdapter( cgManager )->isEquivalentTo( cgManager->getSizeAdapter() )
)
throw GetPrototypeException();
if ( numParams >= 4 )
{
RC::ConstHandle<AST::Param> sharedParam = params->get(3);
if ( sharedParam->getUsage() != CG::USAGE_RVALUE )
throw GetPrototypeException();
sharedDesc = sharedParam->getAdapter( cgManager )->getDesc();
}
}
}
init( functionPtr, numParams, valueDesc, sharedDesc );
}
}
示例9: buildExprValue
CG::ExprValue CreateConstValue::buildExprValue( CG::BasicBlockBuilder &basicBlockBuilder, CG::Usage usage, std::string const &lValueErrorDesc ) const
{
if ( usage == CG::USAGE_LVALUE )
throw Exception( "cannot be used as l-values" );
CG::ExprType childExprType = m_child->getExprType( basicBlockBuilder );
RC::ConstHandle<CG::ValueProducerAdapter> valueProducerAdapter = basicBlockBuilder.getManager()->getValueProducerOf( childExprType.getAdapter() );
RC::Handle<CG::Context> context = basicBlockBuilder.getContext();
llvm::LLVMContext &llvmContext = context->getLLVMContext();
std::vector<llvm::Type const *> argTypes;
argTypes.push_back( llvm::Type::getInt8PtrTy( llvmContext ) );
argTypes.push_back( llvm::Type::getInt8PtrTy( llvmContext ) );
argTypes.push_back( valueProducerAdapter->llvmLType( context ) );
llvm::FunctionType const *funcType = llvm::FunctionType::get( llvm::Type::getVoidTy( llvmContext ), argTypes, false );
llvm::Constant *func = basicBlockBuilder.getModuleBuilder()->getOrInsertFunction( "__MR_CreateConstValue", funcType );
CG::ExprValue childExprRValue = m_child->buildExprValue( basicBlockBuilder, CG::USAGE_RVALUE, lValueErrorDesc );
llvm::Value *childExprLValue = childExprType.getAdapter()->llvmRValueToLValue( basicBlockBuilder, childExprRValue.getValue() );
llvm::Value *resultLValue = valueProducerAdapter->llvmAlloca( basicBlockBuilder, "result" );
valueProducerAdapter->llvmInit( basicBlockBuilder, resultLValue );
basicBlockBuilder.getScope().put(
CG::VariableSymbol::Create(
CG::ExprValue(
valueProducerAdapter,
CG::USAGE_LVALUE,
context,
resultLValue
)
)
);
basicBlockBuilder->CreateCall3(
func,
valueProducerAdapter->llvmAdapterPtr( basicBlockBuilder ),
basicBlockBuilder->CreatePointerCast(
childExprLValue,
llvm::Type::getInt8PtrTy( llvmContext )
),
resultLValue
);
return CG::ExprValue(
valueProducerAdapter,
CG::USAGE_RVALUE,
context,
valueProducerAdapter->llvmLValueToRValue( basicBlockBuilder, resultLValue )
);
}
示例10: llvmRType
void ArrayProducerAdapter::llvmProduce0(
CG::BasicBlockBuilder &basicBlockBuilder,
llvm::Value *arrayProducerRValue,
llvm::Value *dstLValue
) const
{
RC::Handle<Context> context = basicBlockBuilder.getContext();
std::vector<llvm::Type *> argTypes;
argTypes.push_back( basicBlockBuilder->getInt8PtrTy() );
argTypes.push_back( llvmRType( context ) );
argTypes.push_back( m_elementVariableArrayAdapter->llvmLType( context ) );
llvm::FunctionType *funcType = llvm::FunctionType::get( llvm::Type::getVoidTy( context->getLLVMContext() ), argTypes, false );
llvm::Constant *func = basicBlockBuilder.getModuleBuilder()->getOrInsertFunction( "__"+getCodeName()+"__Produce0", funcType );
basicBlockBuilder->CreateCall3( func, llvmAdapterPtr( basicBlockBuilder ), arrayProducerRValue, dstLValue );
}
示例11: registerTypes
void ConstString::registerTypes( RC::Handle<CG::Manager> const &cgManager, CG::Diagnostics &diagnostics ) const
{
std::string unquotedValue;
try
{
unquotedValue = Util::parseQuotedString( m_value );
}
catch ( Exception e )
{
throw CG::Error( getLocation(), e.getDesc() + "(" + m_value + ")" );
}
cgManager->getConstStringAdapter();
cgManager->getStringAdapter();
}
示例12: buildExprValue
CG::ExprValue CreateValueCache::buildExprValue( CG::BasicBlockBuilder &basicBlockBuilder, CG::Usage usage, std::string const &lValueErrorDesc ) const
{
if ( usage == CG::USAGE_LVALUE )
throw Exception( "cannot be used as l-values" );
RC::Handle<CG::Context> context = basicBlockBuilder.getContext();
llvm::LLVMContext &llvmContext = context->getLLVMContext();
CG::ExprType inputExprType = m_input->getExprType( basicBlockBuilder );
if ( !RT::isValueProducer( inputExprType.getAdapter()->getType() ) )
throw CG::Error( getLocation(), "input must be a value producer" );
RC::ConstHandle<CG::ValueProducerAdapter> valueProducerAdapter = RC::ConstHandle<CG::ValueProducerAdapter>::StaticCast( inputExprType.getAdapter() );
RC::ConstHandle<CG::Adapter> valueAdapter = valueProducerAdapter->getValueAdapter();
CG::ExprValue inputExprRValue = m_input->buildExprValue( basicBlockBuilder, CG::USAGE_RVALUE, lValueErrorDesc );
llvm::Value *resultLValue = valueProducerAdapter->llvmAlloca( basicBlockBuilder, "result" );
valueProducerAdapter->llvmInit( basicBlockBuilder, resultLValue );
basicBlockBuilder.getScope().put(
CG::VariableSymbol::Create(
CG::ExprValue(
valueProducerAdapter,
CG::USAGE_LVALUE,
context,
resultLValue
)
)
);
std::vector<llvm::Type const *> argTypes;
argTypes.push_back( valueProducerAdapter->llvmLType( context ) );
argTypes.push_back( valueProducerAdapter->llvmLType( context ) );
llvm::FunctionType const *funcType = llvm::FunctionType::get( llvm::Type::getVoidTy( llvmContext ), argTypes, false );
llvm::Constant *func = basicBlockBuilder.getModuleBuilder()->getOrInsertFunction( "__MR_CreateValueCache", funcType );
basicBlockBuilder->CreateCall2(
func,
inputExprRValue.getValue(),
resultLValue
);
return CG::ExprValue(
valueProducerAdapter,
CG::USAGE_RVALUE,
context,
valueProducerAdapter->llvmLValueToRValue( basicBlockBuilder, resultLValue )
);
}
示例13: Node
ResourceLoadNode::ResourceLoadNode( std::string const &name, RC::Handle<Context> const &context )
: Node( name, context )
, m_fabricResourceStreamData( context->getRTManager() )
, m_firstEvalAfterLoad( false )
, m_keepMemoryCache( false )
, m_asFile( false )
, m_inProgress( false )
, m_streamGeneration( 0 )
, m_resourceManagerWeak( context->getIOManager()->getResourceManager() )
{
RC::ConstHandle<RT::StringDesc> stringDesc = context->getRTManager()->getStringDesc();
RC::ConstHandle<RT::BooleanDesc> booleanDesc = context->getRTManager()->getBooleanDesc();
addMember( "url", stringDesc, stringDesc->getDefaultData() );
addMember( "resource", m_fabricResourceStreamData.getDesc(), m_fabricResourceStreamData.getDesc()->getDefaultData() );
addMember( "keepMemoryCache", booleanDesc, booleanDesc->getDefaultData() );
addMember( "storeDataAsFile", booleanDesc, booleanDesc->getDefaultData() );
}
示例14: RegisterFabricResourceType
void RegisterFabricResourceType( RC::Handle<RT::Manager> const &rtManager )
{
RT::StructMemberInfoVector memberInfos;
RC::ConstHandle<RT::StringDesc> stringDesc = rtManager->getStringDesc();
memberInfos.resize(NB_FABRIC_RESOURCE_MEMBERS);
memberInfos[FABRIC_RESOURCE_DATA_MEMBER_INDEX].name = "data";
memberInfos[FABRIC_RESOURCE_DATA_MEMBER_INDEX].desc = rtManager->getVariableArrayOf( rtManager->getByteDesc() );
memberInfos[FABRIC_RESOURCE_MIMETYPE_MEMBER_INDEX].name = "mimeType";
memberInfos[FABRIC_RESOURCE_MIMETYPE_MEMBER_INDEX].desc = stringDesc;
memberInfos[FABRIC_RESOURCE_EXTENSION_MEMBER_INDEX].name = "extension";
memberInfos[FABRIC_RESOURCE_EXTENSION_MEMBER_INDEX].desc = stringDesc;
memberInfos[FABRIC_RESOURCE_URL_MEMBER_INDEX].name = "url";
memberInfos[FABRIC_RESOURCE_URL_MEMBER_INDEX].desc = stringDesc;
memberInfos[FABRIC_RESOURCE_DATAEXTERNALLOCATION_MEMBER_INDEX].name = "dataExternalLocation";
memberInfos[FABRIC_RESOURCE_DATAEXTERNALLOCATION_MEMBER_INDEX].desc = stringDesc;
rtManager->registerStruct( "FabricResource", memberInfos, 0 );
}
示例15: registerTypes
void MemberDecl::registerTypes( RC::Handle<CG::Manager> const &cgManager, CG::Diagnostics &diagnostics ) const
{
try
{
cgManager->getAdapter( m_type );
}
catch ( Exception e )
{
addError( diagnostics, e );
}
}