Differences From Artifact [c4125134ec]:
- File
src/threading_winapi.m
— part of check-in
[ffb39d1df6]
at
2015-03-30 21:33:29
on branch trunk
— Add OF_NO_RETURN_FUNC
OF_NO_RETURN_FUNC is defined when __attribute__((__noreturn__)) is
supported for functions, whereas OF_NO_RETURN is only defined when it is
supported for both functions and methods. (user: js, size: 3861) [annotate] [blame] [check-ins using]
To Artifact [1b66353934]:
- File src/threading_winapi.m — part of check-in [0e4c54215b] at 2016-04-18 17:21:49 on branch 0.8 — Improve of_condition_wait error handling on Win32 (user: js, size: 3816) [annotate] [blame] [check-ins using]
1 | /* | | | | 1 2 3 4 5 6 7 8 9 10 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * |
︙ | ︙ | |||
165 166 167 168 169 170 171 172 173 174 175 | return true; } bool of_condition_wait(of_condition_t *condition, of_mutex_t *mutex) { if (!of_mutex_unlock(mutex)) return false; of_atomic_int_inc(&condition->count); | > > < | < < < < | > > < | < < < < < | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | return true; } bool of_condition_wait(of_condition_t *condition, of_mutex_t *mutex) { DWORD status; if (!of_mutex_unlock(mutex)) return false; of_atomic_int_inc(&condition->count); status = WaitForSingleObject(condition->event, INFINITE); of_atomic_int_dec(&condition->count); if (!of_mutex_lock(mutex)) return false; return (status == WAIT_OBJECT_0); } bool of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex, of_time_interval_t timeout) { DWORD status; if (!of_mutex_unlock(mutex)) return false; of_atomic_int_inc(&condition->count); status = WaitForSingleObject(condition->event, timeout * 1000); of_atomic_int_dec(&condition->count); if (!of_mutex_lock(mutex)) return false; return (status == WAIT_OBJECT_0); } bool of_condition_free(of_condition_t *condition) { if (condition->count != 0) return false; return CloseHandle(condition->event); } |