# Path: evergreen/core/utils.py
# class Result(object):
#     """
#     Result is an internal object which is meant to be used like a Future, but being more
#     lightweight and supporting a single waiter. Example:
# 
#     result = Result()
# 
#     def f1():
#         with result:
#             some_async_func()
#             return result.get()
# 
#     def some_async_func():
#         # this function runs in a different task
#         ...
#         result.set_value(42)
#     """
# 
#     __slots__ = ['_lock', '_cond', '_locked', '_used', '_exc', '_value']
# 
#     def __init__(self):
#         self._lock = Lock()
#         self._cond = Condition(Lock())
#         self._locked = False
#         self._used = False
#         self._exc = self._value = Null
# 
#     def acquire(self):
#         self._lock.acquire()
#         self._locked = True
# 
#     def release(self):
#         self._lock.release()
#         self._locked = False
#         self._used = False
#         self._exc = self._value = Null
# 
#     def get(self):
#         assert self._locked
#         assert not self._used
#         try:
#             with self._cond:
#                 if self._exc == self._value == Null:
#                     self._cond.wait()
#             if self._exc != Null:
#                 raise self._exc
#             assert self._value != Null
#             return self._value
#         finally:
#             self._used = True
#             self._exc = self._value = Null
# 
#     def set_value(self, value):
#         assert self._locked
#         assert not self._used
#         assert self._exc == self._value == Null
#         with self._cond:
#             self._value = value
#             self._cond.notify_all()
# 
#     def set_exception(self, value):
#         assert self._locked
#         assert not self._used
#         assert self._exc == self._value == Null
#         with self._cond:
#             self._exc = value
#             self._cond.notify_all()
# 
#     def __enter__(self):
#         self.acquire()
# 
#     def __exit__(self, typ, val, tb):
#         self.release()
# 
# Path: evergreen/event.py
# class Event(object):
# 
#     def __init__(self):
#         self._cond = Condition(Lock())
#         self._flag = False
# 
#     def is_set(self):
#         return self._flag
# 
#     def set(self):
#         self._cond.acquire()
#         try:
#             self._flag = True
#             self._cond.notify_all()
#         finally:
#             self._cond.release()
# 
#     def clear(self):
#         self._cond.acquire()
#         try:
#             self._flag = False
#         finally:
#             self._cond.release()
# 
#     def wait(self, timeout=None):
#         self._cond.acquire()
#         try:
#             signaled = self._flag
#             if not signaled:
#                 signaled = self._cond.wait(timeout)
#             return signaled
#         finally:
#             self._cond.release()
# 
# Path: evergreen/io/errno.py
# def _bootstrap():
# 
# Path: evergreen/log.py



import pyuv
import evergreen
from evergreen.core.utils import Result
from evergreen.event import Event
from evergreen.io import errno
from evergreen.log import log
#
# This file is part of Evergreen. See the NOTICE for more information.
#



__all__ = ['UDPEndpoint', 'UDPError']


UDPError = pyuv.error.UDPError


class UDPEndpoint(object):

    def __init__(self):
        loop = evergreen.current.loop
        self._handle = pyuv.UDP(loop._loop)
        self._closed = False

# Path: evergreen/core/utils.py
# class Result(object):
#     """
#     Result is an internal object which is meant to be used like a Future, but being more
#     lightweight and supporting a single waiter. Example:
# 
#     result = Result()
# 
#     def f1():
#         with result:
#             some_async_func()
#             return result.get()
# 
#     def some_async_func():
#         # this function runs in a different task
#         ...
#         result.set_value(42)
#     """
# 
#     __slots__ = ['_lock', '_cond', '_locked', '_used', '_exc', '_value']
# 
#     def __init__(self):
#         self._lock = Lock()
#         self._cond = Condition(Lock())
#         self._locked = False
#         self._used = False
#         self._exc = self._value = Null
# 
#     def acquire(self):
#         self._lock.acquire()
#         self._locked = True
# 
#     def release(self):
#         self._lock.release()
#         self._locked = False
#         self._used = False
#         self._exc = self._value = Null
# 
#     def get(self):
#         assert self._locked
#         assert not self._used
#         try:
#             with self._cond:
#                 if self._exc == self._value == Null:
#                     self._cond.wait()
#             if self._exc != Null:
#                 raise self._exc
#             assert self._value != Null
#             return self._value
#         finally:
#             self._used = True
#             self._exc = self._value = Null
# 
#     def set_value(self, value):
#         assert self._locked
#         assert not self._used
#         assert self._exc == self._value == Null
#         with self._cond:
#             self._value = value
#             self._cond.notify_all()
# 
#     def set_exception(self, value):
#         assert self._locked
#         assert not self._used
#         assert self._exc == self._value == Null
#         with self._cond:
#             self._exc = value
#             self._cond.notify_all()
# 
#     def __enter__(self):
#         self.acquire()
# 
#     def __exit__(self, typ, val, tb):
#         self.release()
# 
# Path: evergreen/event.py
# class Event(object):
# 
#     def __init__(self):
#         self._cond = Condition(Lock())
#         self._flag = False
# 
#     def is_set(self):
#         return self._flag
# 
#     def set(self):
#         self._cond.acquire()
#         try:
#             self._flag = True
#             self._cond.notify_all()
#         finally:
#             self._cond.release()
# 
#     def clear(self):
#         self._cond.acquire()
#         try:
#             self._flag = False
#         finally:
#             self._cond.release()
# 
#     def wait(self, timeout=None):
#         self._cond.acquire()
#         try:
#             signaled = self._flag
#             if not signaled:
#                 signaled = self._cond.wait(timeout)
#             return signaled
#         finally:
#             self._cond.release()
# 
# Path: evergreen/io/errno.py
# def _bootstrap():
# 
# Path: evergreen/log.py



# Path: evergreen/io/udp.py
import pyuv
import evergreen
from evergreen.core.utils import Result
from evergreen.event import Event
from evergreen.io import errno
from evergreen.log import log

#
# This file is part of Evergreen. See the NOTICE for more information.
#



__all__ = ['UDPEndpoint', 'UDPError']


UDPError = pyuv.error.UDPError


class UDPEndpoint(object):

    def __init__(self):
        loop = evergreen.current.loop
        self._handle = pyuv.UDP(loop._loop)
        self._closed = False

        self._receive_result = Result()