Simplify locking in sp_search and sp_search_pv

Avoid to take the lock two times in a tight sequence, the first
in get_next_move() and the second to update sp->moves.

Do all with one lock and so retire the now useless locked version
of get_next_move().

Also fix some theorical race due to comparison sp->bestValue < sp->beta
is done out of lock protection. Finally fix another (harmless but time
waster) race that coudl occur because thread_should_stop() is also
called outside of lock protection.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2010-01-27 17:29:34 +01:00
parent 307909bed8
commit bb968fd42a
4 changed files with 25 additions and 33 deletions

View File

@@ -99,5 +99,9 @@ typedef CRITICAL_SECTION Lock;
#endif
static inline bool lock_grab_bool(Lock* x) {
lock_grab(x);
return true;
}
#endif // !defined(LOCK_H_INCLUDED)