|
|
@ -33,31 +33,32 @@ doRegister(const void * _node, const void * data) |
|
|
TR_HashValue node = (TR_HashValue)_node; |
|
|
TR_HashValue node = (TR_HashValue)_node; |
|
|
TR_EventDispatcher dispatcher = ((void **)data)[0]; |
|
|
TR_EventDispatcher dispatcher = ((void **)data)[0]; |
|
|
TR_EventHandler current_handler = ((void **)data)[1]; |
|
|
TR_EventHandler current_handler = ((void **)data)[1]; |
|
|
TR_HashValue handler_queue_hv; |
|
|
|
|
|
TR_Queue handler_queue; |
|
|
|
|
|
|
|
|
TR_HashValue handler_list_hv; |
|
|
|
|
|
TR_List handler_list; |
|
|
|
|
|
|
|
|
handler_queue_hv = TR_hashGetByVal(dispatcher->handler, node->hash); |
|
|
|
|
|
|
|
|
handler_list_hv = TR_hashGetByVal(dispatcher->handler, node->hash); |
|
|
|
|
|
|
|
|
if (handler_queue_hv) { |
|
|
|
|
|
handler_queue = *(TR_Queue *)handler_queue_hv->value; |
|
|
|
|
|
|
|
|
if (handler_list_hv) { |
|
|
|
|
|
handler_list = *(TR_List *)handler_list_hv->value; |
|
|
} else { |
|
|
} else { |
|
|
handler_queue = TR_new(TR_Queue); |
|
|
|
|
|
((TR_List)handler_queue)->free_msgs = 0; |
|
|
|
|
|
|
|
|
handler_list = TR_new(TR_Queue); |
|
|
|
|
|
handler_list->free_msgs = 0; |
|
|
// TODO change TR_Queue to TR_Dynarray as this is no queue. |
|
|
// TODO change TR_Queue to TR_Dynarray as this is no queue. |
|
|
handler_queue_hv = TR_new( |
|
|
|
|
|
|
|
|
handler_list_hv = TR_new( |
|
|
TR_HashValue, |
|
|
TR_HashValue, |
|
|
node->key, |
|
|
node->key, |
|
|
node->nkey, |
|
|
node->nkey, |
|
|
&handler_queue, |
|
|
|
|
|
sizeof(TR_Queue)); |
|
|
|
|
|
TR_hashAdd(dispatcher->handler, handler_queue_hv); |
|
|
|
|
|
|
|
|
&handler_list, |
|
|
|
|
|
sizeof(TR_List)); |
|
|
|
|
|
TR_hashAdd(dispatcher->handler, handler_list_hv); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
TR_queuePut(handler_queue, current_handler); |
|
|
|
|
|
|
|
|
TR_listPut(handler_list, current_handler); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
void |
|
|
TR_eventDispatcherRegisterHandler(TR_EventDispatcher this, TR_EventHandler handler) |
|
|
|
|
|
|
|
|
TR_eventDispatcherRegisterHandler( |
|
|
|
|
|
TR_EventDispatcher this, TR_EventHandler handler) |
|
|
{ |
|
|
{ |
|
|
void * cb_data[] = { this, handler }; |
|
|
void * cb_data[] = { this, handler }; |
|
|
|
|
|
|
|
|
|