DFBResult CoreInputHub_Create( u32 queue_id, CoreInputHub **ret_hub ) { DFBResult ret; CoreInputHub *hub; D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ ); D_ASSERT( ret_hub != NULL ); ret = One_Initialize(); if (ret) return ret; hub = D_CALLOC( 1, sizeof(CoreInputHub) ); if (!hub) return D_OOM(); direct_mutex_init( &hub->lock ); ret = OneQueue_New( ONE_QUEUE_NO_FLAGS, queue_id, &hub->method_qid ); if (ret) goto error; ret = OneQueue_New( ONE_QUEUE_VIRTUAL, ONE_QID_NONE, &hub->notify_qid ); if (ret) goto error; ret = OneThread_Create( "Input Hub", &hub->thread ); if (ret) goto error; ret = OneThread_AddQueue( hub->thread, hub->method_qid, CoreInputHub_Dispatch, hub ); if (ret) goto error; D_INFO( "Core/Input/Hub: Running at QID %u\n", hub->method_qid ); *ret_hub = hub; return DFB_OK; error: if (hub->thread) OneThread_Destroy( hub->thread ); if (hub->notify_qid) OneQueue_Destroy( hub->notify_qid ); if (hub->method_qid) OneQueue_Destroy( hub->method_qid ); direct_mutex_deinit( &hub->lock ); D_FREE( hub ); return ret; }
DFBResult CoreInputHubClient_Destroy( CoreInputHubClient *client ) { D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ ); OneThread_Destroy( client->thread ); OneQueue_Destroy( client->listen_qid ); if (client->activate_thread) { direct_mutex_lock( &client->lock ); client->activate_stop = true; direct_waitqueue_broadcast( &client->wq ); direct_mutex_unlock( &client->lock ); direct_thread_join( client->activate_thread ); direct_thread_destroy( client->activate_thread ); } direct_mutex_deinit( &client->lock ); direct_waitqueue_deinit( &client->wq ); D_FREE( client ); return DFB_OK; }
DFBResult CoreInputHubClient_Create( u32 remote_qid, const CoreInputHubClientCallbacks *callbacks, void *ctx, CoreInputHubClient **ret_client ) { DFBResult ret; CoreInputHubClient *client; D_DEBUG_AT( Core_InputHub, "%s( QID 0x%08x )\n", __FUNCTION__, remote_qid ); D_ASSERT( callbacks != NULL ); D_ASSERT( ret_client != NULL ); One_Initialize(); client = D_CALLOC( 1, sizeof(CoreInputHubClient) ); if (!client) return D_OOM(); client->remote_qid = remote_qid; client->callbacks = *callbacks; client->ctx = ctx; ret = OneQueue_New( ONE_QUEUE_NO_FLAGS, ONE_QID_NONE, &client->listen_qid ); if (ret) goto error; OneQueue_SetName( client->listen_qid, "InputHub/Listener" ); ret = OneThread_Create( "Input Hub Client", &client->thread ); if (ret) goto error; ret = OneThread_AddQueue( client->thread, client->listen_qid, CoreInputHubClient_Dispatch, client ); if (ret) goto error; direct_mutex_init( &client->lock ); direct_waitqueue_init( &client->wq ); *ret_client = client; return DFB_OK; error: if (client->thread) OneThread_Destroy( client->thread ); if (client->listen_qid) OneQueue_Destroy( client->listen_qid ); D_FREE( client ); return ret; }
DFBResult CoreInputHubClient_Destroy( CoreInputHubClient *client ) { D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ ); OneThread_Destroy( client->thread ); OneQueue_Destroy( client->listen_qid ); D_FREE( client ); return DFB_OK; }
DFBResult CoreInputHub_Destroy( CoreInputHub *hub ) { D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ ); D_ASSERT( hub != NULL ); OneThread_Destroy( hub->thread ); OneQueue_Destroy( hub->notify_qid ); OneQueue_Destroy( hub->method_qid ); direct_mutex_deinit( &hub->lock ); D_FREE( hub ); return DFB_OK; }
static void IFusionDale_One_Destruct( IFusionDale *thiz ) { IFusionDale_One_data *data = thiz->priv; D_DEBUG_AT( IFusionDale_One, "%s (%p)\n", __FUNCTION__, thiz ); if (data->thread) OneThread_Destroy( data->thread ); ShutdownNS( thiz ); One_Shutdown(); if (data->core) fd_core_destroy( data->core, false ); DIRECT_DEALLOCATE_INTERFACE( thiz ); if (ifusiondale_singleton == thiz) ifusiondale_singleton = NULL; }