diff options
author | Nikias Bassen | 2019-10-11 23:08:48 +0200 |
---|---|---|
committer | Nikias Bassen | 2019-10-11 23:10:07 +0200 |
commit | 767fcceaeb456f5e281a6bd1b3f51713e4989293 (patch) | |
tree | d9a01fbea3c1a85f41ca0f033037737739a14629 /src/common.h | |
parent | 75a61508bd3c2013492744fb5aea755e19b01086 (diff) | |
download | idevicerestore-767fcceaeb456f5e281a6bd1b3f51713e4989293.tar.gz idevicerestore-767fcceaeb456f5e281a6bd1b3f51713e4989293.tar.bz2 |
Use condition variable instead of active waiting for device event handling
With some devices and USB hardware the reconnect of a device might actually
be faster than the check interval of the active waiting loop. With mutexes
and a condition variable we will not miss the moment of reconnect anymore,
even if it is really quick (like 7ms, right DanyL?)
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/common.h b/src/common.h index 41a7bc6..87ceaaf 100644 --- a/src/common.h +++ b/src/common.h @@ -38,6 +38,7 @@ extern "C" { #include <libirecovery.h> #include "idevicerestore.h" +#include "thread.h" #define MODE_UNKNOWN -1 #define MODE_WTF 0 @@ -106,6 +107,8 @@ struct idevicerestore_client_t { void* progress_cb_data; irecv_device_event_context_t irecv_e_ctx; void* idevice_e_ctx; + mutex_t device_event_mutex; + cond_t device_event_cond; }; extern struct idevicerestore_mode_t idevicerestore_modes[]; @@ -155,10 +158,6 @@ char* realpath(const char *filename, char *resolved_name); void get_user_input(char *buf, int maxlen, int secure); -#define WAIT_INTERVAL 200000 -#define WAIT_MAX(x) (x * (1000000 / WAIT_INTERVAL)) -#define WAIT_FOR(cond, timeout) { int __repeat = WAIT_MAX(timeout); while (!(cond) && __repeat-- > 0) { __usleep(WAIT_INTERVAL); } } - uint8_t _plist_dict_get_bool(plist_t dict, const char *key); uint64_t _plist_dict_get_uint(plist_t dict, const char *key); |