;ς
§έι?c           @   sp   d  k  l  Z  d k l Z d k l Z l Z d f  d     YZ d e f d     YZ d e f d     YZ d	 S(
   (   s   Queue(   s   FunctionType(   s   corporas
   predicatess   Ghostc           B   s\   t  Z d  Z d   Z d   Z e e d  Z d   Z d   Z d   Z	 d   Z
 d   Z RS(	   s1  effectively, a Generic Function...

    ... with an arbitrary dispatch-method...
    ... where methods are really, just, generically, delegates...
    ... and where new methods/delegates can be easily added to the *tree*.

    This class exists only to serve as a base for derived ghost-classes--
    for reduction of redundant code and so that isinstance(..., Ghost)
    can be used generically to test if pyobjs are first-class ghosts.

    The Ghost class is itself usable, but does little beside wrapping
    a single callable pyobj with ghost-methods.
    c         C   s   | |  _  d  S(   N(   s   handlers   self(   s   selfs   handler(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   __init__   s    c         C   s   d  S(   N(    (   s   selfs   matchs   handler(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   delegate   s    c         C   s   d  S(   N(    (   s   selfs   matchs   handler(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys
   undelegate   s    c         C   s   g  Sd S(   s@   return list of delegates, not including default handler
        N(    (   s   self(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   list_delegates    s     c         G   s   |  i Sd  S(   N(   s   selfs   handler(   s   selfs   object(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   find_handler%   s    c         C   s   t  | |  Sd  S(   N(   s   applys   handlers   corpora(   s   selfs   handlers   corpora(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   apply(   s    c         G   s   |  i |  i |   |  Sd  S(   N(   s   selfs   applys   find_handlers   object(   s   selfs   object(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   handle_object+   s    c         G   s   |  i |   Sd  S(   N(   s   selfs   handle_objects   object(   s   selfs   object(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   __call__.   s    (   s   __name__s
   __module__s   __doc__s   __init__s   delegates   Nones
   undelegates   list_delegatess   find_handlers   applys   handle_objects   __call__(    (    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   Ghost   s    						s   PredicateGhostc           B   sD   t  Z d  Z d   Z e d  Z e e d  Z d   Z d   Z RS(   sB   a very powerful ghost that dispatches on arbitrary predicates
    c         C   s4   t  g |  _ h  t  | <|  _ h  | t  <|  _ d  S(   N(   s   Nones   selfs
   predicatess
   defhandlers   maps   rmap(   s   selfs
   defhandler(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   __init__4   s    c         C   s   t  | t  o" |  i |  i | i | |  nj | t	 j o1 |  i i
 d |  | |  i | <| |  i | <n, t  | t  o |  i | i | |  n d  S(   Ni    (   s
   isinstances   superhandlers   ints   selfs   maps
   predicatess   delegates	   predicates   handlers   Nones   inserts   rmaps   FunctionType(   s   selfs	   predicates   handlers   superhandler(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   delegate9   s    c         C   s   | o2 | |  i j o |  i i |  |  i | =q9 n | oL |  i i |  o5 |  i | } |  i i |  |  i | =|  i | =q n d  S(   N(	   s   matchs   selfs
   predicatess   removes   maps   handlers   rmaps   has_keys   h(   s   selfs   matchs   handlers   h(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys
   undelegateD   s    c         C   s$   |  i i   } | t =| i   Sd  S(   N(   s   selfs   maps   copys   mcopys   Nones   values(   s   selfs   mcopy(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   list_delegatesO   s    c         G   s   d } x |  i D]z } | o |  i | Sq | |   } t |  o | Sq | o5 | o |  i | i | | d  Sq |  i | Sq q Wd  S(   Ni    i   (	   s   depths   selfs
   predicatess   preds   maps   objects   use_thiss   callables   find_handler(   s   selfs   objects   use_thiss   preds   depth(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   find_handlerT   s    
 (	   s   __name__s
   __module__s   __doc__s   __init__s   Nones   delegates
   undelegates   list_delegatess   find_handler(    (    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   PredicateGhost1   s    		s	   Schedulerc           B   s/   t  Z d   Z d   Z e d  Z d   Z RS(   Nc         C   s8   t    |  _ t |  _ | |  _ t i |  |  i i	  d  S(   N(
   s   Queues   selfs   queues   Falses   runnings
   dispatchers   dispatchs   Ghosts   __init__s   put(   s   selfs
   dispatcher(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   __init__d   s    		c         C   sr   |  i i   } | oO t | t t f  o t |  |  qn |  i |  } | o |  |  qn n
 d G| GHd  S(   Ns   discarding false event:(	   s   selfs   queues   gets   events
   isinstances   lists   tuples   maps   dispatch(   s   selfs   event(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys	   iterationj   s    c            sG   t  |  o t   _   d   } n x |   o   i   q* Wd S(   sΙ   Run The Event-Loop.

        This can be called with a nullary predicate to invoke a sub-loop
        and produce modality, e.g.: to implement actions that block
        waiting for responses.
        c              s     i S(   N(   s   selfs   running(    (   s   self(    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   <lambda>   s    N(   s   callables	   conditions   Trues   selfs   runnings	   iteration(   s   selfs	   condition(    (   s   selfs;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   loopv   s     	 
c         C   s   t  |  _ |  t  d  S(   N(   s   Falses   selfs   runnings   None(   s   self(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   stop   s    	(   s   __name__s
   __module__s   __init__s	   iterations   Nones   loops   stop(    (    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys	   Schedulerc   s   		N(	   s   Queues   typess   FunctionTypes   dp2s   corporas
   predicatess   Ghosts   PredicateGhosts	   Scheduler(   s   Ghosts   PredicateGhosts   corporas   Queues	   Schedulers
   predicatess   FunctionType(    (    s;   /usr/home/rozzin/html/pedagogy/race-condition/dp2/ghosts.pys   ?   s
   ,2