Пример #1
0
def test_mutex():
    m.lock()
    coro.spawn(locker, 1)
    coro.spawn(locker, 2)
    coro.yield_and_schedule()
    m.unlock()
    coro.yield_and_schedule()
    coro._exit = 1
Пример #2
0
def test_mutex():
    m.lock()
    coro.spawn(locker, 1)
    coro.spawn(locker, 2)
    coro.yield_and_schedule()
    m.unlock()
    coro.yield_and_schedule()
    coro._exit = 1
Пример #3
0
def test_rw_lock():
    rw_lock.read_lock()
    rw_lock.read_lock()
    # since write_lock will block, let's get someone to unlock the readers
    coro.spawn(unlocker)
    rw_lock.write_lock()
    coro.spawn(reader)
    coro.spawn(writer)
    coro.yield_and_schedule()
    rw_lock.write_unlock()
    coro._exit = 1
Пример #4
0
def test_rw_lock():
    rw_lock.read_lock()
    rw_lock.read_lock()
    # since write_lock will block, let's get someone to unlock the readers
    coro.spawn(unlocker)
    rw_lock.write_lock()
    coro.spawn(reader)
    coro.spawn(writer)
    coro.yield_and_schedule()
    rw_lock.write_unlock()
    coro._exit = 1