Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6910f42d
Kaydet (Commit)
6910f42d
authored
Eki 08, 1994
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
new version by Tim
üst
81a12bce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
condition.py
Demo/threads/condition.py
+0
-0
sync.py
Demo/threads/sync.py
+21
-0
No files found.
Demo/threads/condition.py
0 → 100755
Dosyayı görüntüle @
6910f42d
This diff is collapsed.
Click to expand it.
Demo/threads/sync.py
Dosyayı görüntüle @
6910f42d
...
...
@@ -258,6 +258,15 @@
# writing. Then if some other thread is waiting to write, it's
# allowed to proceed. Else all threads (if any) waiting to read are
# allowed to proceed.
#
# .write_to_read()
# Use instead of a .write_in to declare that the thread is done
# writing but wants to continue reading without other writers
# intervening. If there are other threads waiting to write, they
# are allowed to proceed only if the current thread calls
# .read_out; threads waiting to read are only allowed to proceed
# if there are are no threads waiting to write. (This is a
# weakness of the interface!)
import
thread
...
...
@@ -464,6 +473,18 @@ class mrsw:
self
.
readOK
.
broadcast
()
self
.
rwOK
.
release
()
def
write_to_read
(
self
):
self
.
rwOK
.
acquire
()
if
not
self
.
writing
:
raise
ValueError
,
\
'.write_to_read() invoked without an active writer'
self
.
writing
=
0
self
.
nw
=
self
.
nw
-
1
self
.
nr
=
self
.
nr
+
1
if
not
self
.
nw
:
self
.
readOK
.
broadcast
()
self
.
rwOK
.
release
()
# The rest of the file is a test case, that runs a number of parallelized
# quicksorts in parallel. If it works, you'll get about 600 lines of
# tracing output, with a line like
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment