in src/thread_notifications_dispatcher.c [42:91]
int thread_notifications_dispatcher_init(void)
{
int result;
if (thread_notifications_dispatcher.state != THREAD_NOTIFICATIONS_DISPATCHER_NOT_INITIALIZED)
{
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_001: [ If the module is already initialized, thread_notifications_dispatcher_init shall fail and return a non-zero value. ]*/
LogError("Invalid state: %" PRI_MU_ENUM "",
MU_ENUM_VALUE(THREAD_NOTIFICATIONS_DISPATCHER_STATE, thread_notifications_dispatcher.state));
result = MU_FAILURE;
}
else
{
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_003: [ thread_notifications_dispatcher_init shall create a TCALL_DISPATCHER(THREAD_NOTIFICATION_CALL). ]*/
TCALL_DISPATCHER(THREAD_NOTIFICATION_CALL) call_dispatcher = TCALL_DISPATCHER_CREATE(THREAD_NOTIFICATION_CALL)();
if (call_dispatcher == NULL)
{
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_007: [ If any error occurrs, thread_notifications_dispatcher_init shall fail and return a non-zero value. ]*/
LogError("TCALL_DISPATCHER_CREATE(THREAD_NOTIFICATION_CALL)() failed");
result = MU_FAILURE;
}
else
{
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_004: [ thread_notifications_dispatcher_init shall store in a global variable the TCALL_DISPATCHER(THREAD_NOTIFICATION_CALL). ]*/
TCALL_DISPATCHER_INITIALIZE_MOVE(THREAD_NOTIFICATION_CALL)(&thread_notifications_dispatcher.thread_notifications_call_dispatcher, &call_dispatcher);
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_005: [ thread_notifications_dispatcher_init shall call thread_notifications_lackey_dll_init_callback to register thread_notifications_lackey_dll_cb as the thread notifications callback. ]*/
if (thread_notifications_lackey_dll_init_callback(thread_notifications_lackey_dll_cb) != 0)
{
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_007: [ If any error occurrs, thread_notifications_dispatcher_init shall fail and return a non-zero value. ]*/
LogError("thread_notifications_lackey_dll_init_callback failed");
result = MU_FAILURE;
}
else
{
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_002: [ Otherwise, thread_notifications_dispatcher_init shall initialize the module: ]*/
thread_notifications_dispatcher.state = THREAD_NOTIFICATIONS_DISPATCHER_INITIALIZED;
/* Codes_SRS_THREAD_NOTIFICATIONS_DISPATCHER_01_006: [ thread_notifications_dispatcher_init shall succeed and return 0. ]*/
result = 0;
goto all_ok;
}
TCALL_DISPATCHER_ASSIGN(THREAD_NOTIFICATION_CALL)(&thread_notifications_dispatcher.thread_notifications_call_dispatcher, NULL);
}
}
all_ok:
return result;
}