[pypy-svn] r23955 - pypy/dist/pypy/lib/logic/computation_space
auc at codespeak.net
auc at codespeak.net
Fri Mar 3 18:37:56 CET 2006
Author: auc
Date: Fri Mar 3 18:37:53 2006
New Revision: 23955
Modified:
pypy/dist/pypy/lib/logic/computation_space/computationspace.py
pypy/dist/pypy/lib/logic/computation_space/distributor.py
pypy/dist/pypy/lib/logic/computation_space/test_computationspace.py
Log:
end of simple var update
notes about futures
Modified: pypy/dist/pypy/lib/logic/computation_space/computationspace.py
==============================================================================
--- pypy/dist/pypy/lib/logic/computation_space/computationspace.py (original)
+++ pypy/dist/pypy/lib/logic/computation_space/computationspace.py Fri Mar 3 18:37:53 2006
@@ -1,11 +1,28 @@
# TODO
-# * support several distribution strategies
-# * add a linear constraint solver (vital for fast
+# * [1] adapt other distribution strategies
+# * [5] add a linear constraint solver (vital for fast
# constraint propagation over finite integer domains)
# and other kinds of specialized propagators
-# * make all propagators live in their own threads and
+# * [9] make all propagators live in their own threads and
# be awakened by variable/domains events
+
+# Gert Smolka in
+# http://www.cetic.be/moz2004/talks/MOZ2004.pdf :
+# * Abandon Logic Variables
+# * can be bound everywhere
+# * malicious consummer can bind tail variable of stream
+# * break abstractions
+# * unification not needed
+# * Have Futures instead
+# * Multilisp [Halstead 85]
+# * added to Mozart in 1998
+# * refine logic variable into
+# * consummer end (future)
+# * producer end (promise)
+# * dataflow synchronization + by-need synchronization
+
+
from threading import Thread, Condition, RLock, local
from state import Succeeded, Distributable, Failed, \
@@ -123,10 +140,10 @@
def _init_choose_commit(self):
# create a unique choice point
- # using two vars as channels betwen
+ # using two spaceless vars as channels betwen
# space and distributor threads
- self.CHOOSE = self._make_choice_var()
- self.STABLE = self._make_stable_var()
+ self.CHOOSE = SimpleVar()
+ self.STABLE = SimpleVar()
#-- utilities & instrumentation -----------------------------
@@ -196,13 +213,6 @@
#-- space helpers -----------------------------------------
- def _make_choice_var(self):
- return SimpleVar()
-
- def _make_stable_var(self):
- return SimpleVar()
-
-
def _process(self):
"""wraps the propagator"""
if len(self.event_set):
@@ -266,7 +276,7 @@
"""
# did you ask before ... ?
assert self.STABLE.is_bound()
- self.STABLE = self._make_stable_var()
+ self.STABLE = SimpleVar()
self.CHOOSE.bind(choice)
def choose(self, nb_choices):
Modified: pypy/dist/pypy/lib/logic/computation_space/distributor.py
==============================================================================
--- pypy/dist/pypy/lib/logic/computation_space/distributor.py (original)
+++ pypy/dist/pypy/lib/logic/computation_space/distributor.py Fri Mar 3 18:37:53 2006
@@ -2,6 +2,7 @@
from threading import Thread
from state import Succeeded, Distributable, Failed, Forsaken
from event import Revise
+from variable import SimpleVar
def arrange_domains(cs, variables):
"""build a data structure from var to dom
@@ -153,7 +154,7 @@
print "-- distribution & propagation (%s) --" % self.cs.id
self.distribute(choice-1)
self.cs._process()
- self.cs.CHOOSE = self.cs._make_choice_var()
+ self.cs.CHOOSE = SimpleVar()
self.cs.STABLE.bind(True) # unlocks Ask
print "-- distributor terminated (%s) --" % self.cs.id
Modified: pypy/dist/pypy/lib/logic/computation_space/test_computationspace.py
==============================================================================
--- pypy/dist/pypy/lib/logic/computation_space/test_computationspace.py (original)
+++ pypy/dist/pypy/lib/logic/computation_space/test_computationspace.py Fri Mar 3 18:37:53 2006
@@ -486,6 +486,8 @@
# we need to carefully craft some noop problems
# for these tests
+# also what is tested below is tested in other places
+# so me might want to just forget about it
## def test_ask_success(self):
## spc = newspace(problems.one_solution_problem)
More information about the Pypy-commit
mailing list