This adds a new error code.
I'm using a weak symbol (were supported, ie GCC on linux) for
some kind of forward compatibility.
Fixes T1780
@feature
*/
EAPI Eina_Error EINA_ERROR_OUT_OF_MEMORY = 0;
-
static const char EINA_ERROR_OUT_OF_MEMORY_STR[] = "Out of memory";
+EWAPI Eina_Error EINA_ERROR_TIMEOUT = 0;
+static const char EINA_ERROR_TIMEOUT_STR[] = "Timed out";
+
/**
* @endcond
*/
/* TODO register the eina's basic errors */
EINA_ERROR_OUT_OF_MEMORY = eina_error_msg_static_register(
EINA_ERROR_OUT_OF_MEMORY_STR);
+ EINA_ERROR_TIMEOUT = eina_error_msg_static_register(EINA_ERROR_TIMEOUT_STR);
if (!eina_tls_new(&_eina_last_key))
return EINA_FALSE;
return EINA_TRUE;
#include <time.h>
#include <sys/time.h>
+#include <eina_error.h>
+
typedef struct _Eina_Lock Eina_Lock;
typedef struct _Eina_RWLock Eina_RWLock;
typedef struct _Eina_Condition Eina_Condition;
&(cond->lock->mutex),
&ts);
if (err == 0) r = EINA_TRUE;
- else if (err == EPERM || err == ETIMEDOUT) r = EINA_FALSE;
+ else if (err == EPERM)
+ err = EINA_FALSE;
+ else if (err == ETIMEDOUT)
+ {
+ r = EINA_FALSE;
+ if (&EINA_ERROR_TIMEOUT) eina_error_set(EINA_ERROR_TIMEOUT);
+ }
else EINA_LOCK_ABORT_DEBUG(err, cond_timedwait, cond);
#ifdef EINA_HAVE_DEBUG_THREADS
*/
typedef void (*Eina_TLS_Delete_Cb)(void *ptr);
+/**
+ * @brief Error set when a blocking function timed out.
+ * @since 1.19
+ */
+EWAPI extern Eina_Error EINA_ERROR_TIMEOUT;
+
# include "eina_inline_lock_posix.x"
/**
* @param[in] cond The #Eina_Condition upon which the thread waits.
* @param[in] t The maximum amount of time to wait, in seconds.
*
- * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
+ * @return #EINA_TRUE on success, #EINA_FALSE otherwise. If the operation
+ * timed out, eina error will be set to #EINA_ERROR_TIMEOUT.
*
* @details This function makes a thread block until either a signal is sent to it via
* @p cond or @p t seconds have passed.
delay = (ts2.tv_sec - ts.tv_sec) * 1000L + (ts2.tv_nsec - ts.tv_nsec) / 1000000L;
fail_if(delay < 50);
fail_if(delay > 200);
+ fail_if(eina_error_get() != EINA_ERROR_TIMEOUT);
fail_if(eina_lock_release(&mtcond) != EINA_LOCK_SUCCEED);
eina_thread_join(thread);