summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-03-19 18:25:09 +0200
committerAvi Levin <avi.levin@samsung.com>2015-03-19 18:25:09 +0200
commit21ccd3773795e681756a0380138bd17fad9718ec (patch)
treed90de408214711f4b3c27b6eb0bb390865e5d33d
parentfa8f786d44022aaa07a00c6517d6c69d86e1b787 (diff)
eo: cleaning eo_base_callbacks.cdevs/avilog/callbacks_by_hashed_events
@fix
-rw-r--r--src/lib/eo/eo_base_class.c291
1 files changed, 66 insertions, 225 deletions
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index 23f6db3c13..c27bfbc62f 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -625,17 +625,7 @@ _eo_callbacks_clear(Eo_Base_Data *pd)
625 return; 625 return;
626 626
627 pd->deletions_waiting = EINA_FALSE; 627 pd->deletions_waiting = EINA_FALSE;
628#if 0
629 EINA_INARRAY_FOREACH(pd->callbacks, cb)
630 {
631 628
632 if (cb->delete_me)
633 {
634 // _eo_callback_remove(pd, titr);
635 eina_inarray_remove(pd->callbacks , cb );
636 }
637 }
638#endif
639 eina_inarray_foreach_remove( pd->callbacks, _eo_base_callback_delete_me_check, NULL); 629 eina_inarray_foreach_remove( pd->callbacks, _eo_base_callback_delete_me_check, NULL);
640 630
641 _eo_base_update_callbacks_hash(pd); 631 _eo_base_update_callbacks_hash(pd);
@@ -644,7 +634,7 @@ _eo_callbacks_clear(Eo_Base_Data *pd)
644static void 634static void
645_eo_callbacks_sorted_insert(Eo_Base_Data *pd, Eo_Callback_Description *cb) 635_eo_callbacks_sorted_insert(Eo_Base_Data *pd, Eo_Callback_Description *cb)
646{ 636{
647#if 0 637
648 Eo_Callback_Description *itr, *itrp = NULL; 638 Eo_Callback_Description *itr, *itrp = NULL;
649 for (itr = pd->callbacks; itr && (itr->priority < cb->priority); 639 for (itr = pd->callbacks; itr && (itr->priority < cb->priority);
650 itr = itr->next) 640 itr = itr->next)
@@ -662,7 +652,7 @@ _eo_callbacks_sorted_insert(Eo_Base_Data *pd, Eo_Callback_Description *cb)
662 cb->next = pd->callbacks; 652 cb->next = pd->callbacks;
663 pd->callbacks = cb; 653 pd->callbacks = cb;
664 } 654 }
665#endif 655
666 656
667} 657}
668void set_event_have( const Eo_Event_Description *a , Eo_Base_Data *pd){ 658void set_event_have( const Eo_Event_Description *a , Eo_Base_Data *pd){
@@ -699,10 +689,10 @@ _eo_base_callback_priority_cmp(const void *a, const void *b)
699 689
700EOLIAN static void 690EOLIAN static void
701_eo_base_event_callback_priority_add(Eo *obj, Eo_Base_Data *pd, 691_eo_base_event_callback_priority_add(Eo *obj, Eo_Base_Data *pd,
702 const Eo_Event_Description *desc, 692 const Eo_Event_Description *desc,
703 Eo_Callback_Priority priority, 693 Eo_Callback_Priority priority,
704 Eo_Event_Cb func, 694 Eo_Event_Cb func,
705 const void *user_data) 695 const void *user_data)
706{ 696{
707 Eo_Callback_Description cb; 697 Eo_Callback_Description cb;
708 698
@@ -713,12 +703,12 @@ _eo_base_event_callback_priority_add(Eo *obj, Eo_Base_Data *pd,
713 cb.func_data = (void *) user_data; 703 cb.func_data = (void *) user_data;
714 cb.priority = priority; 704 cb.priority = priority;
715 cb.func_array = EINA_FALSE; 705 cb.func_array = EINA_FALSE;
716 cb.delete_me = EINA_FALSE; 706 cb.delete_me = EINA_FALSE;
717 // _eo_callbacks_sorted_insert(pd, cb); 707 // _eo_callbacks_sorted_insert(pd, cb);
718 eina_inarray_insert_sorted(pd->callbacks, &cb , _eo_base_callback_priority_cmp); 708 eina_inarray_insert_sorted(pd->callbacks, &cb , _eo_base_callback_priority_cmp);
719 709
720//pd->callbacks_hash_dirty = EINA_TRUE; 710 //pd->callbacks_hash_dirty = EINA_TRUE;
721 _eo_base_update_callbacks_hash(pd); 711 _eo_base_update_callbacks_hash(pd);
722 { 712 {
723 const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; 713 const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}};
724 eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, (void *)arr)); 714 eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, (void *)arr));
@@ -753,59 +743,40 @@ _eo_base_event_callback_del(Eo *obj, Eo_Base_Data *pd,
753 return; 743 return;
754 } 744 }
755 745
756
757
758#if 0
759 for (cb = pd->callbacks; cb; cb = cb->next)
760 {
761 if ((cb->items.item.desc == desc) && (cb->items.item.func == func) &&
762 (cb->func_data == user_data))
763 {
764 const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}};
765
766 cb->delete_me = EINA_TRUE;
767 pd->deletions_waiting = EINA_TRUE;
768 _eo_callbacks_clear(pd);
769 eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, (void *)arr); );
770 return;
771 }
772 }
773#endif
774
775 DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data); 746 DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data);
776} 747}
777 748
778EOLIAN static void 749EOLIAN static void
779_eo_base_event_callback_array_priority_add(Eo *obj, Eo_Base_Data *pd, 750_eo_base_event_callback_array_priority_add(Eo *obj, Eo_Base_Data *pd,
780 const Eo_Callback_Array_Item *array, 751 const Eo_Callback_Array_Item *array,
781 Eo_Callback_Priority priority, 752 Eo_Callback_Priority priority,
782 const void *user_data) 753 const void *user_data)
783{ 754{
784 Eo_Callback_Description cb; 755 Eo_Callback_Description cb;
785 756
786 // cb = calloc(1, sizeof(*cb)); 757 // cb = calloc(1, sizeof(*cb));
787 // if (!cb) return; 758 // if (!cb) return;
788 cb.func_data = (void *) user_data; 759 cb.func_data = (void *) user_data;
789 cb.priority = priority; 760 cb.priority = priority;
790 cb.items.item_array = array; 761 cb.items.item_array = array;
791 cb.func_array = EINA_TRUE; 762 cb.func_array = EINA_TRUE;
792 cb.delete_me = EINA_FALSE; 763 cb.delete_me = EINA_FALSE;
793 // _eo_callbacks_sorted_insert(pd, cb); 764 // _eo_callbacks_sorted_insert(pd, cb);
794 eina_inarray_insert_sorted(pd->callbacks, &cb , _eo_base_callback_priority_cmp); 765 eina_inarray_insert_sorted(pd->callbacks, &cb , _eo_base_callback_priority_cmp);
795//pd->callbacks_hash_dirty = EINA_TRUE; 766 //pd->callbacks_hash_dirty = EINA_TRUE;
796 _eo_base_update_callbacks_hash(pd); 767 _eo_base_update_callbacks_hash(pd);
797 768
798 { 769 {
799 eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, (void *)array); ); 770 eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, (void *)array); );
800 } 771 }
801pd->arrays_counter++;//avi debug 772 pd->arrays_counter++;//avi debug
802 const Eo_Callback_Array_Item *it; 773 const Eo_Callback_Array_Item *it;
803 774
804 for (it = cb.items.item_array; it->func; it++) 775 for (it = cb.items.item_array; it->func; it++)
805 { 776 {
806 777
807 set_event_have( it->desc, pd); 778 set_event_have( it->desc, pd);
808 } 779 }
809 780
810} 781}
811 782
@@ -817,20 +788,6 @@ _eo_base_event_callback_array_del(Eo *obj, Eo_Base_Data *pd,
817{ 788{
818 Eo_Callback_Description *cb; 789 Eo_Callback_Description *cb;
819 790
820#if 0
821 for (cb = pd->callbacks; cb; cb = cb->next)
822 {
823 if ((cb->items.item_array == array) && (cb->func_data == user_data))
824 {
825 cb->delete_me = EINA_TRUE;
826 pd->deletions_waiting = EINA_TRUE;
827 _eo_callbacks_clear(pd);
828
829 eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, (void *)array); );
830 return;
831 }
832 }
833#endif
834 791
835 EINA_INARRAY_FOREACH(pd->callbacks, cb) 792 EINA_INARRAY_FOREACH(pd->callbacks, cb)
836 if ((cb->items.item_array == array) && (cb->func_data == user_data)) 793 if ((cb->items.item_array == array) && (cb->func_data == user_data))
@@ -891,113 +848,52 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
891 clock_t start_time = clock(); 848 clock_t start_time = clock();
892 849
893 850
894if(pd->callbacks_hash_dirty){ 851 if(pd->callbacks_hash_dirty){
895 _eo_base_update_callbacks_hash(pd); 852 _eo_base_update_callbacks_hash(pd);
896 //printf("dirty!\n"); 853 //printf("dirty!\n");
897} 854 }
898 int index_hash = _eo_base_get_event_index_hash( desc ); 855 int index_hash = _eo_base_get_event_index_hash( desc );
899if(pd->callbacks_hash[index_hash][0]==-1) 856 if(pd->callbacks_hash[index_hash][0]==-1)
900 goto end; 857 goto end;
901 858
902 859
903 860
904if(pd->callbacks_hash[index_hash][2]==0){//the only one 861 if(pd->callbacks_hash[index_hash][2]==0){//the only one
905 // printf("call the only one!\n"); 862 // printf("call the only one!\n");
906 cb = eina_inarray_nth(pd->callbacks, pd->callbacks_hash[index_hash][0]); 863 cb = eina_inarray_nth(pd->callbacks, pd->callbacks_hash[index_hash][0]);
907 864
908 if (!cb->delete_me) 865 if (!cb->delete_me)
909 { 866 {
910 if(pd->callbacks_hash[index_hash][1]>-1){//array 867 if(pd->callbacks_hash[index_hash][1]>-1){//array
911//printf("array!\n"); 868 //printf("array!\n");
912 const Eo_Callback_Array_Item *it= cb->items.item_array+pd->callbacks_hash[index_hash][1]; 869 const Eo_Callback_Array_Item *it= cb->items.item_array+pd->callbacks_hash[index_hash][1];
913
914
915 if (!_cb_desc_match(it->desc, desc))
916 goto end;//instead of continiue
917 if (!it->desc->unfreezable &&
918 (event_freeze_count || pd->event_freeze_count))
919 goto end;//instead of continiue
920 unsigned int before_func=clock();
921 /* Abort callback calling if the func says so. */
922 if (!it->func((void *) cb->func_data, obj_id, desc,
923 (void *) event_info))
924 {
925 start_time+=clock()-before_func;
926 ret = EINA_FALSE;
927 goto end;
928 }
929 start_time+=clock()-before_func;
930
931 870
932 }
933 else{
934 if (!_cb_desc_match(cb->items.item.desc, desc))
935 goto end;//instead of continiue
936 if ((!cb->items.item.desc
937 || !cb->items.item.desc->unfreezable) &&
938 (event_freeze_count || pd->event_freeze_count))
939 goto end;//instead of continiue
940 unsigned int before_func=clock();
941 /* Abort callback calling if the func says so. */
942 if (!cb->items.item.func((void *) cb->func_data, obj_id, desc,
943 (void *) event_info))
944 {
945 start_time+=clock()-before_func;
946 ret = EINA_FALSE;
947 goto end;
948 }
949 start_time+=clock()-before_func;
950
951 }
952 }
953 goto end;
954 }
955 // printf("cal: more than one for %d\n", index_hash);
956
957#if 0
958int size = eina_inarray_count( pd->callbacks);
959for (int i= index_hash ; i< size; i++){
960 871
961 872 if (!_cb_desc_match(it->desc, desc))
962 pd->called_loop_counter++;//avi debug 873 goto end;//instead of continiue
963cb = eina_inarray_nth(pd->callbacks, i); 874 if (!it->desc->unfreezable &&
964 875 (event_freeze_count || pd->event_freeze_count))
965 if (!cb->delete_me) 876 goto end;//instead of continiue
966 { 877 unsigned int before_func=clock();
967 if (cb->func_array) 878 /* Abort callback calling if the func says so. */
968 { 879 if (!it->func((void *) cb->func_data, obj_id, desc,
969 const Eo_Callback_Array_Item *it; 880 (void *) event_info))
970//int counter = 0;
971 for (it = cb->items.item_array; it->func; it++)
972 { 881 {
973 pd->called_inner_loop_counter++;//avi debug
974 // printf("here arrary index %d \n",counter++);
975 if (!_cb_desc_match(it->desc, desc))
976 continue;
977 if (!it->desc->unfreezable &&
978 (event_freeze_count || pd->event_freeze_count))
979 continue;
980 unsigned int before_func=clock();
981 /* Abort callback calling if the func says so. */
982 if (!it->func((void *) cb->func_data, obj_id, desc,
983 (void *) event_info))
984 {
985 start_time+=clock()-before_func;
986 ret = EINA_FALSE;
987 goto end;
988 }
989 start_time+=clock()-before_func; 882 start_time+=clock()-before_func;
883 ret = EINA_FALSE;
884 goto end;
990 } 885 }
991 } 886 start_time+=clock()-before_func;
992 else 887
993 { 888
994 // printf("here regular callback \n"); 889 }
890 else{
995 if (!_cb_desc_match(cb->items.item.desc, desc)) 891 if (!_cb_desc_match(cb->items.item.desc, desc))
996 continue; 892 goto end;//instead of continiue
997 if ((!cb->items.item.desc 893 if ((!cb->items.item.desc
998 || !cb->items.item.desc->unfreezable) && 894 || !cb->items.item.desc->unfreezable) &&
999 (event_freeze_count || pd->event_freeze_count)) 895 (event_freeze_count || pd->event_freeze_count))
1000 continue; 896 goto end;//instead of continiue
1001 unsigned int before_func=clock(); 897 unsigned int before_func=clock();
1002 /* Abort callback calling if the func says so. */ 898 /* Abort callback calling if the func says so. */
1003 if (!cb->items.item.func((void *) cb->func_data, obj_id, desc, 899 if (!cb->items.item.func((void *) cb->func_data, obj_id, desc,
@@ -1008,13 +904,13 @@ cb = eina_inarray_nth(pd->callbacks, i);
1008 goto end; 904 goto end;
1009 } 905 }
1010 start_time+=clock()-before_func; 906 start_time+=clock()-before_func;
1011 }
1012 }
1013
1014 907
1015} 908 }
909 }
910 goto end;
911 }
912 // printf("cal: more than one for %d\n", index_hash);
1016 913
1017#endif
1018 914
1019 EINA_INARRAY_FOREACH(pd->callbacks, cb) 915 EINA_INARRAY_FOREACH(pd->callbacks, cb)
1020 { 916 {
@@ -1025,11 +921,11 @@ cb = eina_inarray_nth(pd->callbacks, i);
1025 if (cb->func_array) 921 if (cb->func_array)
1026 { 922 {
1027 const Eo_Callback_Array_Item *it; 923 const Eo_Callback_Array_Item *it;
1028//int counter = 0; 924 //int counter = 0;
1029 for (it = cb->items.item_array; it->func; it++) 925 for (it = cb->items.item_array; it->func; it++)
1030 { 926 {
1031 pd->called_inner_loop_counter++;//avi debug 927 pd->called_inner_loop_counter++;//avi debug
1032 // printf("here arrary index %d \n",counter++); 928 // printf("here arrary index %d \n",counter++);
1033 if (!_cb_desc_match(it->desc, desc)) 929 if (!_cb_desc_match(it->desc, desc))
1034 continue; 930 continue;
1035 if (!it->desc->unfreezable && 931 if (!it->desc->unfreezable &&
@@ -1049,7 +945,7 @@ cb = eina_inarray_nth(pd->callbacks, i);
1049 } 945 }
1050 else 946 else
1051 { 947 {
1052 // printf("here regular callback \n"); 948 // printf("here regular callback \n");
1053 if (!_cb_desc_match(cb->items.item.desc, desc)) 949 if (!_cb_desc_match(cb->items.item.desc, desc))
1054 continue; 950 continue;
1055 if ((!cb->items.item.desc 951 if ((!cb->items.item.desc
@@ -1070,61 +966,6 @@ cb = eina_inarray_nth(pd->callbacks, i);
1070 } 966 }
1071 } 967 }
1072 968
1073#if 0
1074 for (cb = pd->callbacks; cb; cb = cb->next)
1075 {
1076pd->called_loop_counter++;//avi debug
1077
1078 if (!cb->delete_me)
1079 {
1080 if (cb->func_array)
1081 {
1082 const Eo_Callback_Array_Item *it;
1083
1084 for (it = cb->items.item_array; it->func; it++)
1085 {
1086pd->called_inner_loop_counter++;//avi debug
1087 if (!_cb_desc_match(it->desc, desc))
1088 continue;
1089 if (!it->desc->unfreezable &&
1090 (event_freeze_count || pd->event_freeze_count))
1091 continue;
1092unsigned int before_func=clock();
1093 /* Abort callback calling if the func says so. */
1094 if (!it->func((void *) cb->func_data, obj_id, desc,
1095 (void *) event_info))
1096 {
1097start_time+=clock()-before_func;
1098 ret = EINA_FALSE;
1099 goto end;
1100 }
1101start_time+=clock()-before_func;
1102 }
1103 }
1104 else
1105 {
1106 if (!_cb_desc_match(cb->items.item.desc, desc))
1107 continue;
1108 if ((!cb->items.item.desc
1109 || !cb->items.item.desc->unfreezable) &&
1110 (event_freeze_count || pd->event_freeze_count))
1111 continue;
1112unsigned int before_func=clock();
1113 /* Abort callback calling if the func says so. */
1114 if (!cb->items.item.func((void *) cb->func_data, obj_id, desc,
1115 (void *) event_info))
1116 {
1117start_time+=clock()-before_func;
1118 ret = EINA_FALSE;
1119 goto end;
1120 }
1121start_time+=clock()-before_func;
1122 }
1123 }
1124 }
1125
1126#endif
1127
1128end: 969end:
1129 pd->called_sum_clocks +=clock()-start_time;//avi dbg 970 pd->called_sum_clocks +=clock()-start_time;//avi dbg
1130 pd->walking_list--; 971 pd->walking_list--;