Ejemplo n.º 1
0
def t1():
    def f(i):
        r = i * 2
        s = "result: %d" % r
        _async.call_from_main_thread(print, s)
    _async.submit_work(f, 2)
    _async.run()
Ejemplo n.º 2
0
def t1():
    def f(i):
        r = i * 2
        s = "result: %d" % r
        _async.call_from_main_thread(print, s)

    _async.submit_work(f, 2)
    _async.run()
Ejemplo n.º 3
0
def t2():
    def f(i):
        return i * 2
    def cb(r):
        s = "result x 2 = %d" % (r * 2)
        _async.call_from_main_thread(print, s)

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
Ejemplo n.º 4
0
def t3():
    d = {}
    def f(i):
        return i * 2
    def cb(r):
        _async.call_from_main_thread(d.__setitem__, ('result', r*2))

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
    print(d)
Ejemplo n.º 5
0
def t2():
    def f(i):
        return i * 2

    def cb(r):
        s = "result x 2 = %d" % (r * 2)
        _async.call_from_main_thread(print, s)

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
Ejemplo n.º 6
0
def t9():
    d = {'foo' : 'bar'}
    def m(x):
        return x.upper()

    def f(i):
        v = _async.call_from_main_thread_and_wait(m, 'foo')
        _async.call_from_main_thread(print, "v: %s" % v)

    _async.submit_work(f, 'foo', None, None, None)
    _async.run()
Ejemplo n.º 7
0
def t3():
    d = {}

    def f(i):
        return i * 2

    def cb(r):
        _async.call_from_main_thread(d.__setitem__, ('result', r * 2))

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
    print(d)
Ejemplo n.º 8
0
def t9():
    d = {'foo': 'bar'}

    def m(x):
        return x.upper()

    def f(i):
        v = _async.call_from_main_thread_and_wait(m, 'foo')
        _async.call_from_main_thread(print, "v: %s" % v)

    _async.submit_work(f, 'foo', None, None, None)
    _async.run()
Ejemplo n.º 9
0
def t6():
    d = {}
    def f(i):
        r = i * 2
        s = "result: %d" % r
        return s

    def cb(s):
        d['foo'] = reversed(s)

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
    print(d)
Ejemplo n.º 10
0
def t5():
    d = {}
    def f(i):
        return i * 12
    def cb(r):
        _async.call_from_main_thread_and_wait(d.__setitem__, ('result', r*2))
        v = _async.call_from_main_thread_and_wait(
            d.__getitem__, 'result'
        )
        _async.call_from_main_thread_and_wait(print, "v: %d" % v)

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
Ejemplo n.º 11
0
def t5():
    d = {}

    def f(i):
        return i * 12

    def cb(r):
        _async.call_from_main_thread_and_wait(d.__setitem__, ('result', r * 2))
        v = _async.call_from_main_thread_and_wait(d.__getitem__, 'result')
        _async.call_from_main_thread_and_wait(print, "v: %d" % v)

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
Ejemplo n.º 12
0
def t6():
    d = {}

    def f(i):
        r = i * 2
        s = "result: %d" % r
        return s

    def cb(s):
        d['foo'] = reversed(s)

    _async.submit_work(f, 2, None, cb, None)
    _async.run()
    print(d)
Ejemplo n.º 13
0
def t8():
    _async.submit_work(f7, None, None, None, None)
    _async.run()
Ejemplo n.º 14
0
def t8():
    _async.submit_work(f7, None, None, None, None)
    _async.run()