Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
cc53ac5c
Commit
cc53ac5c
authored
13 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
fix: read/write mutex improvement
parent
68fb8f45
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ccnode/utils.py
+25
-2
25 additions, 2 deletions
ccnode/utils.py
with
25 additions
and
2 deletions
ccnode/utils.py
+
25
−
2
View file @
cc53ac5c
...
...
@@ -99,6 +99,7 @@ class RWLock(object):
self
.
read
=
self
.
_RLock
(
self
)
self
.
write
=
self
.
_WLock
(
self
)
class
_Lock
(
object
):
'''
'''
...
...
@@ -107,27 +108,49 @@ class RWLock(object):
'''
self
.
_parent
=
rwlock
class
_WLock
(
_Lock
):
'''
'''
def
__enter__
(
self
):
'''
'''
self
.
acquire
()
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
'''
'''
self
.
release
()
def
acquire
(
self
):
'''
'''
with
self
.
_parent
.
_mutex
:
self
.
_parent
.
_writers
+=
1
self
.
_parent
.
_writemutex
.
acquire
()
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
def
release
(
self
):
'''
'''
with
self
.
_parent
.
_mutex
:
self
.
_parent
.
_writers
-=
1
self
.
_parent
.
_writemutex
.
release
()
class
_RLock
(
_Lock
):
'''
'''
def
__enter__
(
self
):
'''
'''
self
.
acquire
()
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
'''
'''
self
.
release
()
def
acquire
(
self
):
'''
'''
self
.
_parent
.
_mutex
.
acquire
()
...
...
@@ -138,7 +161,7 @@ class RWLock(object):
self
.
_parent
.
_readers
+=
1
self
.
_parent
.
_mutex
.
release
()
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
def
release
(
self
):
'''
'''
self
.
_parent
.
_mutex
.
acquire
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment