Merged revisions 76007 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r76007 | antoine.pitrou | 2009-11-01 12:58:22 +0100 (dim., 01 nov. 2009) | 3 lines

  Buffered I/O: optimize lock taking in the common non-contended case.
........
This commit is contained in:
Antoine Pitrou 2009-11-01 12:05:48 +00:00
parent b6b8b513c5
commit 5800b27104
1 changed files with 5 additions and 3 deletions

View File

@ -260,9 +260,11 @@ typedef struct {
#ifdef WITH_THREAD #ifdef WITH_THREAD
#define ENTER_BUFFERED(self) \ #define ENTER_BUFFERED(self) \
if (!PyThread_acquire_lock(self->lock, 0)) { \
Py_BEGIN_ALLOW_THREADS \ Py_BEGIN_ALLOW_THREADS \
PyThread_acquire_lock(self->lock, 1); \ PyThread_acquire_lock(self->lock, 1); \
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS \
}
#define LEAVE_BUFFERED(self) \ #define LEAVE_BUFFERED(self) \
PyThread_release_lock(self->lock); PyThread_release_lock(self->lock);