diff options
author | mats@kindahl-laptop.dnsalias.net <> | 2007-10-01 15:14:58 +0200 |
---|---|---|
committer | mats@kindahl-laptop.dnsalias.net <> | 2007-10-01 15:14:58 +0200 |
commit | 23622616abe144d514812d5b4ac48cba0348f760 (patch) | |
tree | c98baf1c27ac7f53903ea5e069929741af078957 /mysys/my_winthread.c | |
parent | ef3bcaf3dd46d6a4bc7a38d7a50924eb970148c1 (diff) | |
parent | 5dad55cd24e8a82ae8e4b2e63186af57204ef571 (diff) | |
download | mariadb-git-23622616abe144d514812d5b4ac48cba0348f760.tar.gz |
Merge kindahl-laptop.dnsalias.net:/home/bk/b30992-mysql-5.0-rpl
into kindahl-laptop.dnsalias.net:/home/bk/b30992-mysql-5.0-runtime
Diffstat (limited to 'mysys/my_winthread.c')
-rw-r--r-- | mysys/my_winthread.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index 27ccaef4f23..e9fface0521 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -40,6 +40,31 @@ void win_pthread_init(void) pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST); } +/** + Adapter to @c pthread_mutex_trylock() + + @retval 0 Mutex was acquired + @retval EBUSY Mutex was already locked by a thread + @retval EINVAL Mutex could not be acquired due to other error + */ +int +win_pthread_mutex_trylock(pthread_mutex_t *mutex) +{ + switch (WaitForSingleObject(mutex, 0)) { + case WAIT_TIMEOUT: + return EBUSY; + + default: + case WAIT_FAILURE: + return EINVAL; + + case WAIT_OBJECT_0: + case WAIT_ABANDONED: /* The mutex was acquired because it was + * abandoned */ + return 0; + } +} + /* ** We have tried to use '_beginthreadex' instead of '_beginthread' here ** but in this case the program leaks about 512 characters for each |