# Path: gtimer/private/timedloop.py
# class TimedLoop(TimedLoopBase):
# 
#     def __init__(self, *args, **kwargs):
#         self._first = True
#         super(TimedLoop, self).__init__(*args, **kwargs)
# 
#     def next(self):
#         if self._exited:
#             raise LoopError("Attempted loop iteration on already exited loop (need a new loop object).")
#         if self._first:
#             loop.enter_loop(self._name,
#                             self._rgstr_stamps,
#                             self._save_itrs,
#                             self._keep_prev_subdivisions)
#             self._first = False
#             self._started = True
#             self._timer = get_current_timer()
#         else:
#             if get_current_timer() is not self._timer:
#                 raise LoopError("Loop timer mismatch, likely improper subdivision during loop (cannot span iterations).")
#             loop.loop_end(self._loop_end_stamp,
#                           self._end_stamp_unique,
#                           self._keep_end_subdivisions,
#                           self._quick_print)
#         loop.loop_start()
# 
#     __next__ = next
# 
# class TimedFor(TimedLoopBase):
# 
#     def __init__(self, iterable, *args, **kwargs):
#         self._iterable = iterable
#         super(TimedFor, self).__init__(*args, **kwargs)
# 
#     def __iter__(self):
#         if self._exited:
#             raise LoopError("For-loop object already exited (need a new loop object).")
#         loop.enter_loop(self._name,
#                         self._rgstr_stamps,
#                         self._save_itrs,
#                         self._keep_prev_subdivisions)
#         self._timer = get_current_timer()
#         for i in self._iterable:
#             loop.loop_start()
#             self._started = True
#             yield i
#             if self._exited:
#                 raise LoopError("Loop mechanism exited improperly (must break).")
#             if get_current_timer() is not self._timer:
#                 raise LoopError("Loop timer mismatch, likely improper subdivision during loop (cannot span iterations).")
#             loop.loop_end(self._loop_end_stamp,
#                           self._end_stamp_unique,
#                           self._keep_end_subdivisions)
#             self._started = False
#         loop.exit_loop()
#         self._exited = True
# 
# Path: gtimer/public/timer.py
# SET = {'SI': True,  # save iterations
#        'KS': True,  # keep subdivisions
#        'QP': False,  # quick print
#        'UN': True,  # unique (stamp name)
#        }


from gtimer.private.timedloop import TimedLoop, TimedFor
from gtimer.public.timer import SET

"""
Factory functions providing timed loop objects to user.
"""
from __future__ import absolute_import


__all__ = ['timed_loop', 'timed_for']


def timed_loop(name=None,
               rgstr_stamps=None,
               save_itrs=SET['SI'],
               loop_end_stamp=None,
               end_stamp_unique=SET['UN'],

# Path: gtimer/private/timedloop.py
# class TimedLoop(TimedLoopBase):
# 
#     def __init__(self, *args, **kwargs):
#         self._first = True
#         super(TimedLoop, self).__init__(*args, **kwargs)
# 
#     def next(self):
#         if self._exited:
#             raise LoopError("Attempted loop iteration on already exited loop (need a new loop object).")
#         if self._first:
#             loop.enter_loop(self._name,
#                             self._rgstr_stamps,
#                             self._save_itrs,
#                             self._keep_prev_subdivisions)
#             self._first = False
#             self._started = True
#             self._timer = get_current_timer()
#         else:
#             if get_current_timer() is not self._timer:
#                 raise LoopError("Loop timer mismatch, likely improper subdivision during loop (cannot span iterations).")
#             loop.loop_end(self._loop_end_stamp,
#                           self._end_stamp_unique,
#                           self._keep_end_subdivisions,
#                           self._quick_print)
#         loop.loop_start()
# 
#     __next__ = next
# 
# class TimedFor(TimedLoopBase):
# 
#     def __init__(self, iterable, *args, **kwargs):
#         self._iterable = iterable
#         super(TimedFor, self).__init__(*args, **kwargs)
# 
#     def __iter__(self):
#         if self._exited:
#             raise LoopError("For-loop object already exited (need a new loop object).")
#         loop.enter_loop(self._name,
#                         self._rgstr_stamps,
#                         self._save_itrs,
#                         self._keep_prev_subdivisions)
#         self._timer = get_current_timer()
#         for i in self._iterable:
#             loop.loop_start()
#             self._started = True
#             yield i
#             if self._exited:
#                 raise LoopError("Loop mechanism exited improperly (must break).")
#             if get_current_timer() is not self._timer:
#                 raise LoopError("Loop timer mismatch, likely improper subdivision during loop (cannot span iterations).")
#             loop.loop_end(self._loop_end_stamp,
#                           self._end_stamp_unique,
#                           self._keep_end_subdivisions)
#             self._started = False
#         loop.exit_loop()
#         self._exited = True
# 
# Path: gtimer/public/timer.py
# SET = {'SI': True,  # save iterations
#        'KS': True,  # keep subdivisions
#        'QP': False,  # quick print
#        'UN': True,  # unique (stamp name)
#        }


# Path: gtimer/public/timedloop.py
from gtimer.private.timedloop import TimedLoop, TimedFor
from gtimer.public.timer import SET


"""
Factory functions providing timed loop objects to user.
"""
from __future__ import absolute_import


__all__ = ['timed_loop', 'timed_for']


def timed_loop(name=None,
               rgstr_stamps=None,
               save_itrs=SET['SI'],
               loop_end_stamp=None,
               end_stamp_unique=SET['UN'],

               keep_prev_subdivisions=SET['KS'],