//-------------------------------------------------------------------------------------------------- void msgService_Init ( void ) //-------------------------------------------------------------------------------------------------- { // Create and initialize the pool of Service objects. ServicePoolRef = le_mem_CreatePool("MessagingServices", sizeof(Service_t)); le_mem_ExpandPool(ServicePoolRef, MAX_EXPECTED_SERVICES); le_mem_SetDestructor(ServicePoolRef, ServiceDestructor); // Create and initialize the pool of event handlers objects. HandlerEventPoolRef = le_mem_CreatePool("HandlerEventPool", sizeof(SessionEventHandler_t)); le_mem_ExpandPool(HandlerEventPoolRef, MAX_EXPECTED_SERVICES*6); // Create safe reference map for add references. HandlersRefMap = le_ref_CreateMap("HandlersRef", MAX_EXPECTED_SERVICES*6); // Create the Service Map. ServiceMapRef = le_hashmap_Create("MessagingServices", MAX_EXPECTED_SERVICES, ComputeServiceIdHash, AreServiceIdsTheSame); // Create the key to be used to identify thread-local data records containing the Message // Reference when running a Service's message receive handler. int result = pthread_key_create(&ThreadLocalRxMsgKey, NULL); if (result != 0) { LE_FATAL("Failed to create thread local key: result = %d (%s).", result, strerror(result)); } }
//-------------------------------------------------------------------------------------------------- void tu_Init ( void ) //-------------------------------------------------------------------------------------------------- { LE_DEBUG("** Initialize Tree User subsystem."); LE_ASSERT(sizeof(uint32_t) >= sizeof(uid_t)); // Startup the internal Legato user API. user_Init(); // Create our memory pools and allocate the info for the root user. UserPoolRef = le_mem_CreatePool(CFG_USER_POOL_NAME, sizeof(User_t)); UserCollectionRef = le_hashmap_Create(CFG_USER_COLLECTION_NAME, 31, le_hashmap_HashUInt32, le_hashmap_EqualsUInt32); le_mem_SetDestructor(UserPoolRef, UserDestructor); // Create our default root user/tree association. CreateUserInfo(0, "root", "system"); }
//-------------------------------------------------------------------------------------------------- static le_result_t InitializeTimerContainer ( void ) { WatchdogPool = le_mem_CreatePool("WatchdogPool", sizeof(WatchdogObj_t)); WatchdogRefsContainer = le_hashmap_Create( "wdog_watchdogRefsContainer", LE_WDOG_HASTABLE_WIDTH, le_hashmap_HashUInt32, le_hashmap_EqualsUInt32 ); LE_ASSERT(WatchdogRefsContainer != NULL); return LE_OK; }
int mangoh_bridge_air_vantage_init(mangoh_bridge_air_vantage_t* airVantage, void* bridge) { int32_t res = LE_OK; LE_ASSERT(airVantage); LE_DEBUG("init"); airVantage->bridge = bridge; airVantage->dataUpdateHandlers = le_hashmap_Create(MANGOH_BRIDGE_AIR_VANTAGE_DATA_UPDATE_MAP_NAME, MANGOH_BRIDGE_AIR_VANTAGE_DATA_UPDATE_MAP_SIZE, le_hashmap_HashString, le_hashmap_EqualsString); res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_SESSION_START, airVantage, mangoh_bridge_air_vantage_sessionStart); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_SESSION_END, airVantage, mangoh_bridge_air_vantage_sessionEnd); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_SUBSCRIBE, airVantage, mangoh_bridge_air_vantage_subscribe); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_PUSH_BOOLEAN, airVantage, mangoh_bridge_air_vantage_pushBoolean); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_PUSH_INTEGER, airVantage, mangoh_bridge_air_vantage_pushInteger); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_PUSH_FLOAT, airVantage, mangoh_bridge_air_vantage_pushFloat); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_PUSH_STRING, airVantage, mangoh_bridge_air_vantage_pushString); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_AVAILABLE, airVantage, mangoh_bridge_air_vantage_available); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerCommandProcessor(airVantage->bridge, MANGOH_BRIDGE_AIR_VANTAGE_RECV, airVantage, mangoh_bridge_air_vantage_recv); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerCommandProcessor() failed(%d)", res); goto cleanup; } res = mangoh_bridge_registerReset(airVantage->bridge, airVantage, mangoh_bridge_air_vantage_reset); if (res != LE_OK) { LE_ERROR("ERROR mangoh_bridge_registerReset() failed(%d)", res); goto cleanup; } cleanup: LE_DEBUG("init completed(%d)", res); return res; }