5 self
.lock
= threading
.Condition()
8 def enqueue(self
,call
):
11 self
.queue
.append(call
)
23 class JSFunctionCall(object):
25 self
.lock
= threading
.Lock()
28 def free(self
, result
):
33 class JSFunctionFactory(object):
34 def __init__(self
,queue
,server
):
38 def createFunction(self
,args
,code
,name
):
39 return JSFunction(args
,code
,name
,self
.queue
,self
.server
)
41 class JSFunction(cached
=False):
42 def __init__(self
,args
,code
,name
):
48 def getDefinition(self
):
49 return "function %s {\n%s}\n" % (self
.name
, self
.code
)
51 def __call__(self
,*args
):
56 ff
= JSFunctionFactory(q
,s
)
58 dreieck
= ff
.createFunction(['a','b'],"""
59 return Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
63 print "a=%s,b=%s => c=%s" % (i
, i
*2, dreieck(i
, i
*2))