Ñò
 „Pc        
   @   sç   d  Z  d d k Z d d k Z y d d k l Z Wn# e j
 o d d k l Z n Xd d k l Z l Z l	 Z	 l
 Z
 d Z d e i i f d „  ƒ  YZ e ƒ  a d „  Z d	 „  Z d
 „  Z e i e ƒ d e f d „  ƒ  YZ d S(   s+   
Runner.py: Task scheduling and execution

iÿÿÿÿN(   t   Queue(   t   Utilst   Taskt   Errorst   Logsi
   t   TaskConsumerc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   st   
	Task consumers belong to a pool of workers

	They wait for tasks in the queue and then use ``task.process(...)``
	c         C   s:   t  i i i |  ƒ t ƒ  |  _ |  i d ƒ |  i ƒ  d  S(   Ni   (   R   t	   threadingt   Threadt   __init__R    t   readyt	   setDaemont   start(   t   self(    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyR      s    c         C   s(   y |  i  ƒ  Wn t j
 o n Xd S(   s$   
		Loop over the tasks to execute
		N(   t   loopt	   Exception(   R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   run%   s    c         C   sD   x= |  i  i ƒ  } t | t i ƒ p | |  ƒ q | i ƒ  q d S(   s    
		Obtain tasks from :py:attr:`waflib.Runner.TaskConsumer.ready` and call
		:py:meth:`waflib.Task.TaskBase.process`. If the object is a function, execute it.
		N(   R	   t   gett
   isinstanceR   t   TaskBaset   process(   R   t   tsk(    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyR   .   s
    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyR      s   				c           C   s/   y t  i t ƒ SWn t j
 o t ƒ  SXd S(   sæ   
	Obtain a task consumer from :py:attr:`waflib.Runner.pool`.
	Do not forget to put it back by using :py:func:`waflib.Runner.put_pool`
	and reset properly (original waiting queue).

	:rtype: :py:class:`waflib.Runner.TaskConsumer`
	N(   t   poolR   t   FalseR   R   (    (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   get_pool?   s    c         C   s   t  i |  ƒ d S(   s   
	Return a task consumer to the thread pool :py:attr:`waflib.Runner.pool`

	:param x: task consumer object
	:type x: :py:class:`waflib.Runner.TaskConsumer`
	N(   R   t   put(   t   x(    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   put_poolL   s    c          C   st   g  }  x% t  i ƒ  o |  i t  i ƒ  ƒ q	 Wx |  D] } | i i d  ƒ q5 Wx |  D] } | i ƒ  qV Wd  a  d  S(   N(   R   t   qsizet   appendR   R	   R   t   Nonet   join(   t   lstR   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   _free_resourcesU   s       t   Parallelc           B   st   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z RS(   sE   
	Schedule the tasks obtained from the build context for execution.
	i   c         C   sm   | |  _  | |  _ g  |  _ g  |  _ t d ƒ |  _ d |  _ d |  _ t |  _	 g  |  _
 d |  _ t |  _ d S(   se   
		The initialization requires a build context reference
		for computing the total number of jobs.
		i    i   N(   t   numjobst   bldt   outstandingt   frozenR    t   outt   countt	   processedR   t   stopt   errorR    t   bitert   dirty(   R   R&   t   j(    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyR   e   s    										c         C   s   |  i  p d S|  i  i d ƒ S(   sR   
		Obtain the next task to execute.

		:rtype: :py:class:`waflib.Task.TaskBase`
		i    N(   R'   R    t   pop(   R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   get_next_task   s    
c         C   s>   t  i d d ƒ o |  i i d | ƒ n |  i i | ƒ d S(   s­   
		A task cannot be executed at this point, put it in the list :py:attr:`waflib.Runner.Parallel.frozen`.

		:param tsk: task
		:type tsk: :py:class:`waflib.Task.TaskBase`
		i    i   N(   t   randomt   randintR(   t   insertR   (   R   R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   postponeš   s    c         C   s·  x& |  i  |  i t j o |  i ƒ  q Wx‡|  i p||  i  o |  i ƒ  nþ |  i oó y |  i |  i j } Wn t j
 o n¹ X| o° d } x& |  i D] } | i	 p d } Pq› q› Wg  } xR |  i D]G } | i
 d t | ƒ g  } | i	 D] } | t | ƒ qð ~ f ƒ qÊ Wt i d | d i | ƒ f ƒ ‚ n |  i |  _ n |  i o |  i |  i 7_ g  |  _ q, |  i  p0 |  i i t |  i ƒ ƒ |  i i ƒ  |  _ Pq, q, Wd S(   s^   
		Put the next group of tasks to execute in :py:attr:`waflib.Runner.Parallel.outstanding`.
		s#   check the build order for the taskss!   check the methods runnable_statuss   %s	-> %rs   Deadlock detected: %s%st    N(   R*   R%   t   GAPt   get_outR'   R(   t   deadlockR+   t   AttributeErrort	   run_afterR   t   reprt   idR   t   WafErrorR!   t   extendt   nextR.   R&   t   total(   R   t   condt   msgR   R"   t   _[1]R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   refill_task_list¦   s@      



 
	
 E&

c         C   sE   t  | d d ƒ o. |  i | i 7_ |  i t | i ƒ 7_ n d S(   s½   
		Tasks may be added dynamically during the build by binding them to the task :py:attr:`waflib.Task.TaskBase.more_tasks`

		:param tsk: task
		:type tsk: :py:attr:`waflib.Task.TaskBase`
		t
   more_tasksN(   t   getattrR    R'   RG   RB   t   len(   R   R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   add_more_tasksÊ   s    c         C   sF   |  i  i ƒ  } |  i p |  i | ƒ n |  i d 8_ t |  _ | S(   sÕ   
		Obtain one task returned from the task consumers, and update the task count. Add more tasks if necessary through
		:py:attr:`waflib.Runner.Parallel.add_more_tasks`.

		:rtype: :py:attr:`waflib.Task.TaskBase`
		i   (   R)   R   R,   RJ   R*   t   TrueR/   (   R   R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyR9   Õ   s    
	c         C   s.   |  i  i p t |  _ n |  i i | ƒ d S(   sÞ   
		Called when a task cannot be executed. The flag :py:attr:`waflib.Runner.Parallel.stop` is set, unless
		the build is executed with::

			$ waf build -k

		:param tsk: task
		:type tsk: :py:attr:`waflib.Task.TaskBase`
		N(   R&   t   keepRK   R,   R-   R   (   R   R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   error_handlerã   s    
c         C   s?   y |  i  Wn t j
 o |  i ƒ  n X|  i i | ƒ d S(   sa   
		Pass a task to a consumer.

		:param tsk: task
		:type tsk: :py:attr:`waflib.Task.TaskBase`
		N(   R   R;   t   init_task_poolR	   R   (   R   R   (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   add_taskñ   s
    c            sw   g  } t  ˆ  i ƒ D] } | t ƒ  q ~ } ˆ  _ t d ƒ ˆ  _ ‡  f d †  } x | D] } | i i | ƒ qY W| S(   Ni    c            s   ˆ  i  |  _  d  S(   N(   R	   (   t   consumer(   R   (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   setq  s    (   t   rangeR%   R   R   R    R	   R   (   R   RE   t   iR   RQ   R   (    (   R   s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyRN   þ   s    4 c            s–   ‡  f d †  } y ˆ  i  } Wn t j
 o nb Xx | D] } ˆ  i i | ƒ q9 Wx | D] } ˆ  i ƒ  qZ Wx | D] } t | ƒ qu Wg  ˆ  _  d  S(   Nc            s#   t  d ƒ |  _ ˆ  i i ˆ  ƒ d  S(   Ni    (   R    R	   R)   R   (   RP   (   R   (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyRQ   
  s    (   R   R;   R	   R   R9   R   (   R   RQ   R   R   (    (   R   s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   free_task_pool  s       c         C   s  |  i  i ƒ  |  _ x3|  i p(|  i ƒ  |  i ƒ  } | p |  i o q qR Pn | i o |  i d 7_ q n |  i o Pn y | i ƒ  } Wnë t	 j
 oß |  i d 7_ t
 i ƒ  | _ |  i o“ |  i  i o† t i | _ |  i  i d j o< t i d j p |  i o |  i i | ƒ n t |  _ q t i d j o |  i i | ƒ q q n t i | _ |  i | ƒ q n X| t i j o |  i | ƒ q | t i j o, |  i d 7_ t i | _ |  i | ƒ q |  i |  i f | _ |  i d 7_ |  | _ |  i d 7_ |  i d j o | i ƒ  q |  i | ƒ q Wx# |  i o |  i o |  i  ƒ  qKW|  i d j p |  i p t! ‚ |  i" ƒ  d S(   sË   
		Give tasks to :py:class:`waflib.Runner.TaskConsumer` instances until the build finishes or the ``stop`` flag is set.
		If only one job is used, then execute the tasks one by one, without consumers.
		i   i    N(#   R&   RB   R,   RF   R2   R*   t   hasrunR+   t   runnable_statusR   R   t   ex_stackt   err_msgRL   R   t   SKIPPEDR   t   verboseR-   R   RK   t	   EXCEPTIONRM   t	   ASK_LATERR6   t   SKIP_MERJ   t   positiont   masterR%   R   RO   R9   t   AssertionErrorRT   (   R   R   t   st(    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyR     sb     




	 !(   R   R   R   R   R2   R6   RF   RJ   R9   RM   RO   RN   RT   R   (    (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyR$   a   s   +	
		$					
	(   R   R3   t   atexitt   queueR    t   ImportErrort   waflibR   R   R   R   R8   R   R   R   R   R   R   R#   t   registert   objectR$   (    (    (    s:   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Runner.pyt   <module>   s   "$					
