return void* for data functions; depend on user not to be stupid (hahahahahah)

fix doxy to display correctly and be accurate once again
TODO: add functions to rwlock global data while threads are modifying it?


SVN revision: 50692
This commit is contained in:
Mike Blumenkrantz 2010-07-30 20:33:32 +00:00
parent 81644c5029
commit 122ec75b01
3 changed files with 78 additions and 41 deletions

View File

@ -369,14 +369,14 @@ extern "C" {
EAPI Eina_Bool ecore_thread_pool_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct); EAPI Eina_Bool ecore_thread_pool_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
EAPI void *ecore_thread_pool_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb); EAPI void *ecore_thread_pool_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb);
EAPI const void *ecore_thread_pool_data_find(Ecore_Thread *thread, const char *key); EAPI void *ecore_thread_pool_data_find(Ecore_Thread *thread, const char *key);
EAPI Eina_Bool ecore_thread_pool_data_del(Ecore_Thread *thread, const char *key); EAPI Eina_Bool ecore_thread_pool_data_del(Ecore_Thread *thread, const char *key);
EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct); EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
EAPI void *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb); EAPI void *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb);
EAPI const void *ecore_thread_global_data_find(const char *key); EAPI void *ecore_thread_global_data_find(const char *key);
EAPI Eina_Bool ecore_thread_global_data_del(const char *key); EAPI Eina_Bool ecore_thread_global_data_del(const char *key);
EAPI const void *ecore_thread_global_data_wait(const char *key, double seconds); EAPI void *ecore_thread_global_data_wait(const char *key, double seconds);

View File

@ -843,13 +843,15 @@ ecore_thread_available_get(void)
* @param thread The thread context to add to * @param thread The thread context to add to
* @param key The name string to add the data with * @param key The name string to add the data with
* @param value The data to add * @param value The data to add
* @param cb The callback to free the data with
* @param direct If true, this will not copy the key string (like eina_hash_direct_add) * @param direct If true, this will not copy the key string (like eina_hash_direct_add)
* @return EINA_TRUE on success, EINA_FALSE on failure * @return EINA_TRUE on success, EINA_FALSE on failure
* This adds data to the thread context, allowing for subsequent users of the thread's pool * This adds data to the thread context, allowing for subsequent users of the thread's pool
* to retrieve and use it without complicated mutexing. This function can only be called by a * to retrieve and use it without complicated mutexing. This function can only be called by a
* *_run thread INSIDE the thread and will return EINA_FALSE in any case but success. * *_run thread INSIDE the thread and will return EINA_FALSE in any case but success.
* All data added to the thread pool must be freed in the thread's func_end/func_cancel * All data added to the thread pool will be freed with its associated callback (if present)
* functions to avoid leaks. * upon thread termination. If no callback is specified, it is expected that the user will free the
* data, but this is most likely not what you want.
*/ */
EAPI Eina_Bool EAPI Eina_Bool
ecore_thread_pool_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct) ecore_thread_pool_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct)
@ -891,12 +893,14 @@ ecore_thread_pool_data_add(Ecore_Thread *thread, const char *key, void *value, E
* @param thread The thread context * @param thread The thread context
* @param key The name string to add the data with * @param key The name string to add the data with
* @param value The data to add * @param value The data to add
* @param cb The callback to free the data with
* @param direct If true, this will not copy the key string (like eina_hash_direct_add) * @param direct If true, this will not copy the key string (like eina_hash_direct_add)
* @return The old data associated with @p key on success if modified, NULL if added * @return The old data associated with @p key on success if modified, NULL if added
* This adds/modifies data in the thread context, adding only if modify fails. * This adds/modifies data in the thread context, adding only if modify fails.
* This function can only be called by a *_run thread INSIDE the thread. * This function can only be called by a *_run thread INSIDE the thread.
* All data added to the thread pool must be freed in the thread's func_end/func_cancel * All data added to the thread pool will be freed with its associated callback (if present)
* functions to avoid leaks. * upon thread termination. If no callback is specified, it is expected that the user will free the
* data, but this is most likely not what you want.
*/ */
EAPI void * EAPI void *
ecore_thread_pool_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb) ecore_thread_pool_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb)
@ -941,7 +945,7 @@ ecore_thread_pool_data_set(Ecore_Thread *thread, const char *key, void *value, E
* in any case but success. * in any case but success.
*/ */
EAPI const void * EAPI void *
ecore_thread_pool_data_find(Ecore_Thread *thread, const char *key) ecore_thread_pool_data_find(Ecore_Thread *thread, const char *key)
{ {
Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread; Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
@ -969,7 +973,7 @@ ecore_thread_pool_data_find(Ecore_Thread *thread, const char *key)
* @return EINA_TRUE on success, EINA_FALSE on failure * @return EINA_TRUE on success, EINA_FALSE on failure
* This deletes the data pointer from the thread context which was previously added with @ref ecore_thread_pool_data_add * This deletes the data pointer from the thread context which was previously added with @ref ecore_thread_pool_data_add
* This function can only be called by a *_run thread INSIDE the thread, and will return EINA_FALSE * This function can only be called by a *_run thread INSIDE the thread, and will return EINA_FALSE
* in any case but success. Note that this WILL NOT free the data, it merely removes it from the thread pool. * in any case but success. Note that this WILL free the data if a callback was specified.
*/ */
EAPI Eina_Bool EAPI Eina_Bool
ecore_thread_pool_data_del(Ecore_Thread *thread, const char *key) ecore_thread_pool_data_del(Ecore_Thread *thread, const char *key)
@ -1000,7 +1004,8 @@ ecore_thread_pool_data_del(Ecore_Thread *thread, const char *key)
* @return EINA_TRUE on success, EINA_FALSE on failure * @return EINA_TRUE on success, EINA_FALSE on failure
* This adds data to the global thread data, and will return EINA_FALSE in any case but success. * This adds data to the global thread data, and will return EINA_FALSE in any case but success.
* All data added to global can be manually freed, or a callback can be provided with @p cb which will * All data added to global can be manually freed, or a callback can be provided with @p cb which will
* be called upon ecore_thread shutting down. * be called upon ecore_thread shutting down. Note that if you have manually freed data that a callback
* was specified for, you will most likely encounter a segv later on.
*/ */
EAPI Eina_Bool EAPI Eina_Bool
ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct) ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct)
@ -1047,7 +1052,8 @@ ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina
* associated with @p key and returning the previous data if it existed. To see if an error occurred, * associated with @p key and returning the previous data if it existed. To see if an error occurred,
* one must use eina_error_get. * one must use eina_error_get.
* All data added to global can be manually freed, or a callback can be provided with @p cb which will * All data added to global can be manually freed, or a callback can be provided with @p cb which will
* be called upon ecore_thread shutting down. * be called upon ecore_thread shutting down. Note that if you have manually freed data that a callback
* was specified for, you will most likely encounter a segv later on.
*/ */
EAPI void * EAPI void *
ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb) ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb)
@ -1091,9 +1097,14 @@ ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb)
* @return The value, or NULL on error * @return The value, or NULL on error
* This finds data in the global data that has been previously added with @ref ecore_thread_global_data_add * This finds data in the global data that has been previously added with @ref ecore_thread_global_data_add
* This function will return NULL in any case but success. * This function will return NULL in any case but success.
* All data added to global can be manually freed, or a callback can be provided with @p cb which will
* be called upon ecore_thread shutting down. Note that if you have manually freed data that a callback
* was specified for, you will most likely encounter a segv later on.
* @note Keep in mind that the data returned can be used by multiple threads at a time, so you will most likely want to mutex
* if you will be doing anything with it.
*/ */
EAPI const void * EAPI void *
ecore_thread_global_data_find(const char *key) ecore_thread_global_data_find(const char *key)
{ {
Ecore_Thread_Data *ret; Ecore_Thread_Data *ret;
@ -1151,8 +1162,10 @@ ecore_thread_global_data_del(const char *key)
* This finds data in the global data that has been previously added with @ref ecore_thread_global_data_add * This finds data in the global data that has been previously added with @ref ecore_thread_global_data_add
* This function will return NULL in any case but success. * This function will return NULL in any case but success.
* Use @p seconds to specify the amount of time to wait. Use > 0 for an actual wait time, 0 to not wait, and < 0 to wait indefinitely. * Use @p seconds to specify the amount of time to wait. Use > 0 for an actual wait time, 0 to not wait, and < 0 to wait indefinitely.
* @note Keep in mind that the data returned can be used by multiple threads at a time, so you will most likely want to mutex
* if you will be doing anything with it.
*/ */
EAPI const void * EAPI void *
ecore_thread_global_data_wait(const char *key, double seconds) ecore_thread_global_data_wait(const char *key, double seconds)
{ {
double time = 0; double time = 0;

View File

@ -142,20 +142,29 @@ typedef void (*Ecore_Con_Dns_Cb)(const char *canonname,
*/ */
typedef enum _Ecore_Con_Type typedef enum _Ecore_Con_Type
{ {
ECORE_CON_LOCAL_USER = 0, /** Socket in ~/.ecore */ /** Socket in ~/.ecore */
ECORE_CON_LOCAL_SYSTEM = 1, /** Socket in /tmp */ ECORE_CON_LOCAL_USER = 0,
ECORE_CON_LOCAL_ABSTRACT = 2, /** Abstract socket */ /** Socket in /tmp */
ECORE_CON_REMOTE_TCP = 3, /** Remote server using TCP */ ECORE_CON_LOCAL_SYSTEM = 1,
ECORE_CON_REMOTE_MCAST = 4, /** Remote multicast server */ /** Abstract socket */
ECORE_CON_REMOTE_UDP = 5, /** Remote server using UDP */ ECORE_CON_LOCAL_ABSTRACT = 2,
ECORE_CON_REMOTE_BROADCAST = 6, /** Remote broadcast using UDP */ /** Remote server using TCP */
ECORE_CON_REMOTE_TCP = 3,
/** Remote multicast server */
ECORE_CON_REMOTE_MCAST = 4,
/** Remote server using UDP */
ECORE_CON_REMOTE_UDP = 5,
/** Remote broadcast using UDP */
ECORE_CON_REMOTE_BROADCAST = 6,
ECORE_CON_REMOTE_NODELAY = 7, ECORE_CON_REMOTE_NODELAY = 7,
/** Use SSL2: UNSUPPORTED. **/
ECORE_CON_USE_SSL2 = (1 << 4), /** Use SSL2: UNSUPPORTED. **/ ECORE_CON_USE_SSL2 = (1 << 4),
ECORE_CON_USE_SSL3 = (1 << 5), /** Use SSL3 */ /** Use SSL3 */
ECORE_CON_USE_TLS = (1 << 6), /** Use TLS */ ECORE_CON_USE_SSL3 = (1 << 5),
/** Use TLS */
ECORE_CON_LOAD_CERT = (1 << 7) /** Attempt to use the previously loaded certificate */ ECORE_CON_USE_TLS = (1 << 6),
/** Attempt to use the previously loaded certificate */
ECORE_CON_LOAD_CERT = (1 << 7)
} Ecore_Con_Type; } Ecore_Con_Type;
#define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2 #define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2
#define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP #define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP
@ -257,9 +266,12 @@ struct _Ecore_Con_Event_Server_Del
*/ */
struct _Ecore_Con_Event_Client_Data struct _Ecore_Con_Event_Client_Data
{ {
Ecore_Con_Client *client; /** the client that connected */ /** the client that connected */
void *data; /** the data that the client sent */ Ecore_Con_Client *client;
int size; /** the length of the data sent */ /** the data that the client sent */
void *data;
/** the length of the data sent */
int size;
}; };
/** /**
@ -268,9 +280,12 @@ struct _Ecore_Con_Event_Client_Data
*/ */
struct _Ecore_Con_Event_Server_Data struct _Ecore_Con_Event_Server_Data
{ {
Ecore_Con_Server *server; /** the server that was connected to */ /** the server that was connected to */
void *data; /** the data that the server sent */ Ecore_Con_Server *server;
int size; /** the length of the data sent */ /** the data that the server sent */
void *data;
/** the length of the data sent */
int size;
}; };
/** /**
@ -313,15 +328,24 @@ struct _Ecore_Con_Event_Url_Progress
} up; } up;
}; };
EAPI extern int ECORE_CON_EVENT_CLIENT_ADD; /** A client has connected to the server */ /** A client has connected to the server */
EAPI extern int ECORE_CON_EVENT_CLIENT_DEL; /** A client has disconnected from the server */ EAPI extern int ECORE_CON_EVENT_CLIENT_ADD;
EAPI extern int ECORE_CON_EVENT_SERVER_ADD; /** A server was created */ /** A client has disconnected from the server */
EAPI extern int ECORE_CON_EVENT_SERVER_DEL; /** A server connection was lost */ EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA; /** A client connected to the server has sent data */ /** A server was created */
EAPI extern int ECORE_CON_EVENT_SERVER_DATA; /** A server connection object has data */ EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
EAPI extern int ECORE_CON_EVENT_URL_DATA; /** A URL object has data */ /** A server connection was lost */
EAPI extern int ECORE_CON_EVENT_URL_COMPLETE; /** A URL object has completed its transfer to and from the server and can be reused */ EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
EAPI extern int ECORE_CON_EVENT_URL_PROGRESS; /** A URL object has made progress in its transfer */ /** A client connected to the server has sent data */
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
/** A server connection object has data */
EAPI extern int ECORE_CON_EVENT_SERVER_DATA;
/** A URL object has data */
EAPI extern int ECORE_CON_EVENT_URL_DATA;
/** A URL object has completed its transfer to and from the server and can be reused */
EAPI extern int ECORE_CON_EVENT_URL_COMPLETE;
/** A URL object has made progress in its transfer */
EAPI extern int ECORE_CON_EVENT_URL_PROGRESS;
/** /**
* @} * @}
*/ */