Changeset 3666

Show
Ignore:
Timestamp:
05/14/08 19:01:54
Author:
jdapena
Message:

* Use GOnce registering all types in tinymail to make

registering thread-safe.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3664 r3666  
     12008-05-14  Jose Dapena Paz  <jdapena@igalia.com> 
     2 
     3        * Use GOnce registering all types in tinymail to make 
     4        registering thread-safe. 
     5 
    162008-05-14  Philip Van Hoof <pvanhoof@gnome.org> 
    27 
  • trunk/libtinymail-acap/tny-acap-account-store.c

    r3304 r3666  
    226226 
    227227 
     228static gpointer 
     229tny_acap_account_store_register_type (gpointer notused) 
     230{ 
     231        GType type = 0; 
     232 
     233        static const GTypeInfo info =  
     234                { 
     235                        sizeof (TnyAcapAccountStoreClass), 
     236                        NULL,   /* base_init */ 
     237                        NULL,   /* base_finalize */ 
     238                        (GClassInitFunc) tny_acap_account_store_class_init,   /* class_init */ 
     239                        NULL,   /* class_finalize */ 
     240                        NULL,   /* class_data */ 
     241                        sizeof (TnyAcapAccountStore), 
     242                        0,      /* n_preallocs */ 
     243                        tny_acap_account_store_instance_init    /* instance_init */ 
     244                }; 
     245         
     246        static const GInterfaceInfo tny_account_store_info =  
     247                { 
     248                        (GInterfaceInitFunc) tny_account_store_init, /* interface_init */ 
     249                        NULL,         /* interface_finalize */ 
     250                        NULL          /* interface_data */ 
     251                }; 
     252         
     253        type = g_type_register_static (G_TYPE_OBJECT, 
     254                                       "TnyAcapAccountStore", 
     255                                       &info, 0); 
     256         
     257        g_type_add_interface_static (type, TNY_TYPE_ACCOUNT_STORE,  
     258                                     &tny_account_store_info); 
     259 
     260        return GUINT_TO_POINTER (type); 
     261} 
     262 
    228263GType  
    229264tny_acap_account_store_get_type (void) 
    230265{ 
    231         static GType type = 0; 
    232  
    233         if (G_UNLIKELY(type == 0)) 
    234         { 
    235                 static const GTypeInfo info =  
    236                 { 
    237                   sizeof (TnyAcapAccountStoreClass), 
    238                   NULL,   /* base_init */ 
    239                   NULL,   /* base_finalize */ 
    240                   (GClassInitFunc) tny_acap_account_store_class_init,   /* class_init */ 
    241                   NULL,   /* class_finalize */ 
    242                   NULL,   /* class_data */ 
    243                   sizeof (TnyAcapAccountStore), 
    244                   0,      /* n_preallocs */ 
    245                   tny_acap_account_store_instance_init    /* instance_init */ 
    246                 }; 
    247  
    248                 static const GInterfaceInfo tny_account_store_info =  
    249                 { 
    250                   (GInterfaceInitFunc) tny_account_store_init, /* interface_init */ 
    251                   NULL,         /* interface_finalize */ 
    252                   NULL          /* interface_data */ 
    253                 }; 
    254  
    255                 type = g_type_register_static (G_TYPE_OBJECT, 
    256                         "TnyAcapAccountStore", 
    257                         &info, 0); 
    258  
    259                 g_type_add_interface_static (type, TNY_TYPE_ACCOUNT_STORE,  
    260                         &tny_account_store_info); 
    261         } 
    262  
    263         return type; 
    264 
     266        static GOnce once = G_ONCE_INIT; 
     267        g_once (&once, tny_acap_account_store_register_type, NULL); 
     268        return GPOINTER_TO_UINT (once.retval); 
     269
  • trunk/libtinymail-camel/tny-camel-account.c

    r3654 r3666  
    23252325} 
    23262326 
     2327static gpointer  
     2328tny_camel_account_register_type (gpointer notused) 
     2329{ 
     2330        GType type = 0; 
     2331 
     2332        static const GTypeInfo info =  
     2333                { 
     2334                        sizeof (TnyCamelAccountClass), 
     2335                        NULL,   /* base_init */ 
     2336                        NULL,   /* base_finalize */ 
     2337                        (GClassInitFunc) tny_camel_account_class_init,   /* class_init */ 
     2338                        NULL,   /* class_finalize */ 
     2339                        NULL,   /* class_data */ 
     2340                        sizeof (TnyCamelAccount), 
     2341                        0,      /* n_preallocs */ 
     2342                        tny_camel_account_instance_init    /* instance_init */ 
     2343                }; 
     2344         
     2345        static const GInterfaceInfo tny_account_info =  
     2346                { 
     2347                        (GInterfaceInitFunc) tny_account_init, /* interface_init */ 
     2348                        NULL,         /* interface_finalize */ 
     2349                        NULL          /* interface_data */ 
     2350                }; 
     2351         
     2352        type = g_type_register_static (G_TYPE_OBJECT, 
     2353                                       "TnyCamelAccount", 
     2354                                       &info, 0); 
     2355         
     2356        g_type_add_interface_static (type, TNY_TYPE_ACCOUNT,  
     2357                                     &tny_account_info); 
     2358         
     2359 
     2360        return GUINT_TO_POINTER (type); 
     2361} 
     2362 
    23272363/** 
    23282364 * tny_camel_account_get_type: 
     
    23352371tny_camel_account_get_type (void) 
    23362372{ 
    2337         static GType type = 0
     2373        static GOnce once = G_ONCE_INIT
    23382374 
    23392375        if (G_UNLIKELY (!_camel_type_init_done)) 
     
    23452381        } 
    23462382 
    2347         if (G_UNLIKELY(type == 0)) 
    2348         { 
    2349                 static const GTypeInfo info =  
    2350                 { 
    2351                   sizeof (TnyCamelAccountClass), 
    2352                   NULL,   /* base_init */ 
    2353                   NULL,   /* base_finalize */ 
    2354                   (GClassInitFunc) tny_camel_account_class_init,   /* class_init */ 
    2355                   NULL,   /* class_finalize */ 
    2356                   NULL,   /* class_data */ 
    2357                   sizeof (TnyCamelAccount), 
    2358                   0,      /* n_preallocs */ 
    2359                   tny_camel_account_instance_init    /* instance_init */ 
    2360                 }; 
    2361  
    2362                 static const GInterfaceInfo tny_account_info =  
    2363                 { 
    2364                   (GInterfaceInitFunc) tny_account_init, /* interface_init */ 
    2365                   NULL,         /* interface_finalize */ 
    2366                   NULL          /* interface_data */ 
    2367                 }; 
    2368  
    2369                 type = g_type_register_static (G_TYPE_OBJECT, 
    2370                         "TnyCamelAccount", 
    2371                         &info, 0); 
    2372  
    2373                 g_type_add_interface_static (type, TNY_TYPE_ACCOUNT,  
    2374                         &tny_account_info); 
    2375  
    2376         } 
    2377  
    2378         return type; 
    2379 
    2380  
     2383        g_once (&once, tny_camel_account_register_type, NULL); 
     2384        return GPOINTER_TO_UINT (once.retval); 
     2385
  • trunk/libtinymail-camel/tny-camel-bs-mime-part.c

    r3663 r3666  
    11411141} 
    11421142 
     1143static gpointer  
     1144tny_camel_bs_mime_part_register_type (gpointer notused) 
     1145{ 
     1146        GType type = 0; 
     1147 
     1148        static const GTypeInfo info =  
     1149                { 
     1150                        sizeof (TnyCamelBsMimePartClass), 
     1151                        NULL,   /* base_init */ 
     1152                        NULL,   /* base_finalize */ 
     1153                        (GClassInitFunc) tny_camel_bs_mime_part_class_init,   /* class_init */ 
     1154                        NULL,   /* class_finalize */ 
     1155                        NULL,   /* class_data */ 
     1156                        sizeof (TnyCamelBsMimePart), 
     1157                        0,      /* n_preallocs */ 
     1158                        tny_camel_bs_mime_part_instance_init,    /* instance_init */ 
     1159                        NULL 
     1160                }; 
     1161 
     1162        static const GInterfaceInfo tny_mime_part_info =  
     1163                { 
     1164                        (GInterfaceInitFunc) tny_mime_part_init, /* interface_init */ 
     1165                        NULL,         /* interface_finalize */ 
     1166                        NULL          /* interface_data */ 
     1167                }; 
     1168         
     1169        type = g_type_register_static (G_TYPE_OBJECT, 
     1170                                       "TnyCamelBsMimePart", 
     1171                                       &info, 0); 
     1172         
     1173        g_type_add_interface_static (type, TNY_TYPE_MIME_PART,  
     1174                                     &tny_mime_part_info); 
     1175 
     1176        return GUINT_TO_POINTER (type); 
     1177} 
     1178 
    11431179/** 
    11441180 * tny_camel_bs_mime_part_get_type: 
     
    11511187tny_camel_bs_mime_part_get_type (void) 
    11521188{ 
    1153         static GType type = 0
     1189        static GOnce once = G_ONCE_INIT
    11541190 
    11551191        if (G_UNLIKELY (!_camel_type_init_done)) 
     
    11621198        } 
    11631199 
    1164         if (G_UNLIKELY(type == 0)) 
    1165         { 
    1166                 static const GTypeInfo info =  
    1167                 { 
    1168                   sizeof (TnyCamelBsMimePartClass), 
    1169                   NULL,   /* base_init */ 
    1170                   NULL,   /* base_finalize */ 
    1171                   (GClassInitFunc) tny_camel_bs_mime_part_class_init,   /* class_init */ 
    1172                   NULL,   /* class_finalize */ 
    1173                   NULL,   /* class_data */ 
    1174                   sizeof (TnyCamelBsMimePart), 
    1175                   0,      /* n_preallocs */ 
    1176                   tny_camel_bs_mime_part_instance_init,    /* instance_init */ 
    1177                   NULL 
    1178                 }; 
    1179  
    1180                 static const GInterfaceInfo tny_mime_part_info =  
    1181                 { 
    1182                   (GInterfaceInitFunc) tny_mime_part_init, /* interface_init */ 
    1183                   NULL,         /* interface_finalize */ 
    1184                   NULL          /* interface_data */ 
    1185                 }; 
    1186  
    1187                 type = g_type_register_static (G_TYPE_OBJECT, 
    1188                         "TnyCamelBsMimePart", 
    1189                         &info, 0); 
    1190  
    1191                 g_type_add_interface_static (type, TNY_TYPE_MIME_PART,  
    1192                         &tny_mime_part_info); 
    1193         } 
    1194  
    1195         return type; 
    1196 
     1200        g_once (&once, tny_camel_bs_mime_part_register_type, NULL); 
     1201        return GPOINTER_TO_UINT (once.retval); 
     1202
  • trunk/libtinymail-camel/tny-camel-bs-msg-header.c

    r3526 r3666  
    255255 
    256256 
     257static gpointer  
     258tny_camel_bs_msg_header_register_type (gpointer notused) 
     259{ 
     260        GType type = 0; 
     261 
     262        static const GTypeInfo info =  
     263                { 
     264                        sizeof (TnyCamelBsMsgHeaderClass), 
     265                        NULL,   /* base_init */ 
     266                        NULL,   /* base_finalize */ 
     267                        (GClassInitFunc) tny_camel_bs_msg_header_class_init,   /* class_init */ 
     268                        NULL,   /* class_finalize */ 
     269                        NULL,   /* class_data */ 
     270                        sizeof (TnyCamelBsMsgHeader), 
     271                        0,      /* n_preallocs */ 
     272                        NULL,    /* instance_init */ 
     273                        NULL 
     274                }; 
     275         
     276        static const GInterfaceInfo tny_header_info =  
     277                { 
     278                        (GInterfaceInitFunc) tny_header_init, /* interface_init */ 
     279                        NULL,         /* interface_finalize */ 
     280                        NULL          /* interface_data */ 
     281                }; 
     282         
     283        type = g_type_register_static (G_TYPE_OBJECT, 
     284                                       "TnyCamelBsMsgHeader", 
     285                                       &info, 0); 
     286         
     287        g_type_add_interface_static (type, TNY_TYPE_HEADER,  
     288                                     &tny_header_info); 
     289 
     290        return GUINT_TO_POINTER (type); 
     291} 
     292 
    257293/** 
    258294 * tny_camel_bs_msg_header_get_type: 
     
    265301tny_camel_bs_msg_header_get_type (void) 
    266302{ 
    267         static GType type = 0
     303        static GOnce once = G_ONCE_INIT
    268304 
    269305        if (G_UNLIKELY (!_camel_type_init_done)) 
     
    276312        } 
    277313 
    278         if (G_UNLIKELY(type == 0)) 
    279         { 
    280                 static const GTypeInfo info =  
    281                 { 
    282                   sizeof (TnyCamelBsMsgHeaderClass), 
    283                   NULL,   /* base_init */ 
    284                   NULL,   /* base_finalize */ 
    285                   (GClassInitFunc) tny_camel_bs_msg_header_class_init,   /* class_init */ 
    286                   NULL,   /* class_finalize */ 
    287                   NULL,   /* class_data */ 
    288                   sizeof (TnyCamelBsMsgHeader), 
    289                   0,      /* n_preallocs */ 
    290                   NULL,    /* instance_init */ 
    291                   NULL 
    292                 }; 
    293  
    294                 static const GInterfaceInfo tny_header_info =  
    295                 { 
    296                   (GInterfaceInitFunc) tny_header_init, /* interface_init */ 
    297                   NULL,         /* interface_finalize */ 
    298                   NULL          /* interface_data */ 
    299                 }; 
    300  
    301                 type = g_type_register_static (G_TYPE_OBJECT, 
    302                         "TnyCamelBsMsgHeader", 
    303                         &info, 0); 
    304  
    305                 g_type_add_interface_static (type, TNY_TYPE_HEADER,  
    306                         &tny_header_info); 
    307         } 
    308  
    309         return type; 
    310 
     314        g_once (&once, tny_camel_bs_msg_header_register_type, NULL); 
     315        return GPOINTER_TO_UINT (once.retval); 
     316
  • trunk/libtinymail-camel/tny-camel-bs-msg-receive-strategy.c

    r3654 r3666  
    207207 
    208208 
    209 GType 
    210 tny_camel_bs_msg_receive_strategy_get_type (void) 
    211 
    212         static GType type = 0; 
    213         if (G_UNLIKELY(type == 0)) 
    214         { 
    215                 static const GTypeInfo info =  
     209static gpointer 
     210tny_camel_bs_msg_receive_strategy_register_type (gpointer notused) 
     211
     212        GType type = 0; 
     213        static const GTypeInfo info =  
    216214                { 
    217215                        sizeof (TnyCamelBsMsgReceiveStrategyClass), 
     
    228226 
    229227 
    230                static const GInterfaceInfo tny_msg_receive_strategy_info =  
     228        static const GInterfaceInfo tny_msg_receive_strategy_info =  
    231229                { 
    232230                        (GInterfaceInitFunc) tny_msg_receive_strategy_init, /* interface_init */ 
     
    234232                        NULL          /* interface_data */ 
    235233                }; 
    236  
    237                 type = g_type_register_static (G_TYPE_OBJECT, 
    238                         "TnyCamelBsMsgReceiveStrategy", 
    239                         &info, 0); 
    240  
    241                 g_type_add_interface_static (type, TNY_TYPE_MSG_RECEIVE_STRATEGY, 
    242                         &tny_msg_receive_strategy_info); 
    243  
    244         } 
    245         return type; 
    246 
     234         
     235        type = g_type_register_static (G_TYPE_OBJECT, 
     236                                       "TnyCamelBsMsgReceiveStrategy", 
     237                                       &info, 0); 
     238         
     239        g_type_add_interface_static (type, TNY_TYPE_MSG_RECEIVE_STRATEGY, 
     240                                     &tny_msg_receive_strategy_info); 
     241         
     242        return GUINT_TO_POINTER (type); 
     243
     244 
     245GType 
     246tny_camel_bs_msg_receive_strategy_get_type (void) 
     247
     248        static GOnce once = G_ONCE_INIT; 
     249        g_once (&once, tny_camel_bs_msg_receive_strategy_register_type, NULL); 
     250        return GPOINTER_TO_UINT (once.retval); 
     251
  • trunk/libtinymail-camel/tny-camel-bs-msg.c

    r3526 r3666  
    291291} 
    292292 
     293static gpointer 
     294tny_camel_bs_msg_register_type (gpointer notused) 
     295{ 
     296        GType type = 0; 
     297 
     298        static const GTypeInfo info =  
     299                { 
     300                        sizeof (TnyCamelBsMsgClass), 
     301                        NULL,   /* base_init */ 
     302                        NULL,   /* base_finalize */ 
     303                        (GClassInitFunc) tny_camel_bs_msg_class_init, /* class_init */ 
     304                        NULL,   /* class_finalize */ 
     305                        NULL,   /* class_data */ 
     306                        sizeof (TnyCamelBsMsg), 
     307                        0,      /* n_preallocs */ 
     308                        tny_camel_bs_msg_instance_init,    /* instance_init */ 
     309                        NULL 
     310                }; 
     311         
     312        static const GInterfaceInfo tny_msg_info =  
     313                { 
     314                        (GInterfaceInitFunc) tny_msg_init, /* interface_init */ 
     315                        NULL,         /* interface_finalize */ 
     316                        NULL          /* interface_data */ 
     317                }; 
     318         
     319        type = g_type_register_static (TNY_TYPE_CAMEL_BS_MIME_PART, 
     320                                       "TnyCamelBsMsg", 
     321                                       &info, 0); 
     322         
     323        g_type_add_interface_static (type, TNY_TYPE_MSG, 
     324                                     &tny_msg_info); 
     325 
     326        return GUINT_TO_POINTER (type); 
     327} 
     328 
    293329/** 
    294330 * tny_camel_bs_msg_get_type: 
     
    301337tny_camel_bs_msg_get_type (void) 
    302338{ 
    303         static GType type = 0
     339        static GOnce once = G_ONCE_INIT
    304340 
    305341        if (G_UNLIKELY (!_camel_type_init_done)) 
     
    312348        } 
    313349 
    314         if (G_UNLIKELY(type == 0)) 
    315           { 
    316             static const GTypeInfo info =  
    317                   { 
    318                   sizeof (TnyCamelBsMsgClass), 
    319                   NULL,   /* base_init */ 
    320                   NULL,   /* base_finalize */ 
    321                   (GClassInitFunc) tny_camel_bs_msg_class_init, /* class_init */ 
    322                   NULL,   /* class_finalize */ 
    323                   NULL,   /* class_data */ 
    324                   sizeof (TnyCamelBsMsg), 
    325                   0,      /* n_preallocs */ 
    326                   tny_camel_bs_msg_instance_init,    /* instance_init */ 
    327                   NULL 
    328                 }; 
    329                  
    330                 static const GInterfaceInfo tny_msg_info =  
    331                   { 
    332                   (GInterfaceInitFunc) tny_msg_init, /* interface_init */ 
    333                   NULL,         /* interface_finalize */ 
    334                   NULL          /* interface_data */ 
    335                 }; 
    336                  
    337                 type = g_type_register_static (TNY_TYPE_CAMEL_BS_MIME_PART, 
    338                                                "TnyCamelBsMsg", 
    339                                                &info, 0); 
    340  
    341                 g_type_add_interface_static (type, TNY_TYPE_MSG, 
    342                                              &tny_msg_info); 
    343         } 
    344  
    345         return type; 
    346 
    347  
     350        g_once (&once, tny_camel_bs_msg_register_type, NULL); 
     351        return GPOINTER_TO_UINT (once.retval); 
     352
  • trunk/libtinymail-camel/tny-camel-default-connection-policy.c

    r3304 r3666  
    7878} 
    7979 
    80 GType 
    81 tny_camel_default_connection_policy_get_type (void) 
     80static gpointer 
     81tny_camel_default_connection_policy_register_type (gpointer notused) 
    8282{ 
    83         static GType type = 0; 
    84         if (G_UNLIKELY(type == 0)) 
    85         { 
    86                 static const GTypeInfo info =  
     83        GType type = 0; 
     84        static const GTypeInfo info =  
    8785                { 
    8886                        sizeof (TnyCamelDefaultConnectionPolicyClass), 
     
    9795                        NULL 
    9896                }; 
    99  
    100  
    101                static const GInterfaceInfo tny_connection_policy_info =  
     97         
     98         
     99        static const GInterfaceInfo tny_connection_policy_info =  
    102100                { 
    103101                        (GInterfaceInitFunc) tny_connection_policy_init, /* interface_init */ 
     
    105103                        NULL          /* interface_data */ 
    106104                }; 
     105         
     106        type = g_type_register_static (G_TYPE_OBJECT, 
     107                                       "TnyCamelDefaultConnectionPolicy", 
     108                                       &info, 0); 
     109         
     110        g_type_add_interface_static (type, TNY_TYPE_CONNECTION_POLICY, 
     111                                     &tny_connection_policy_info); 
     112         
     113        return GUINT_TO_POINTER (type); 
     114} 
    107115 
    108                 type = g_type_register_static (G_TYPE_OBJECT, 
    109                         "TnyCamelDefaultConnectionPolicy", 
    110                         &info, 0); 
    111  
    112                 g_type_add_interface_static (type, TNY_TYPE_CONNECTION_POLICY, 
    113                         &tny_connection_policy_info); 
    114  
    115         } 
    116         return type; 
     116GType 
     117tny_camel_default_connection_policy_get_type (void) 
     118
     119        static GOnce once = G_ONCE_INIT; 
     120        g_once (&once, tny_camel_default_connection_policy_register_type, NULL); 
     121        return GPOINTER_TO_UINT (once.retval); 
    117122} 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r3654 r3666  
    62416241} 
    62426242 
     6243static gpointer  
     6244tny_camel_folder_register_type (gpointer notused) 
     6245{ 
     6246        GType type = 0; 
     6247         
     6248        static const GTypeInfo info =  
     6249                { 
     6250                        sizeof (TnyCamelFolderClass), 
     6251                        NULL,   /* base_init */ 
     6252                        NULL,   /* base_finalize */ 
     6253                        (GClassInitFunc) tny_camel_folder_class_init,   /* class_init */ 
     6254                        NULL,   /* class_finalize */ 
     6255                        NULL,   /* class_data */ 
     6256                        sizeof (TnyCamelFolder), 
     6257                        0,      /* n_preallocs */ 
     6258                        tny_camel_folder_instance_init    /* instance_init */ 
     6259                }; 
     6260         
     6261        static const GInterfaceInfo tny_folder_info =  
     6262                { 
     6263                        (GInterfaceInitFunc) tny_folder_init, /* interface_init */ 
     6264                        NULL,         /* interface_finalize */ 
     6265                        NULL          /* interface_data */ 
     6266                }; 
     6267         
     6268        static const GInterfaceInfo tny_folder_store_info =  
     6269                { 
     6270                        (GInterfaceInitFunc) tny_folder_store_init, /* interface_init */<