
    01i
                     8    S SK Jr   " S S5      r " S S5      rg)    )Lockc                   8    \ rS rSrSrSS/rS rS rS rS r	S	r
g
)ResponsibleGenerator   z?A generator that will help clean up when it is done being used.cleanupgenc                     X l         Xl        g Nr   r   )selfr   r   s      Z/home/james-whalen/.local/lib/python3.13/site-packages/rdflib/plugins/stores/concurrent.py__init__ResponsibleGenerator.__init__	   s        c                 $    U R                  5         g r
   )r   r   s    r   __del__ResponsibleGenerator.__del__   s    r   c                     U $ r
    r   s    r   __iter__ResponsibleGenerator.__iter__   s    r   c                 ,    [        U R                  5      $ r
   )nextr   r   s    r   __next__ResponsibleGenerator.__next__   s    DHH~r   r   N)__name__
__module____qualname____firstlineno____doc__	__slots__r   r   r   r   __static_attributes__r   r   r   r   r      s#    IE"Ir   r   c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)ConcurrentStore   z0A store that allows concurrent reads and writes.c                 X    Xl         SU l        [        5       U l        / U l        / U l        g Nr   )store_ConcurrentStore__visit_countr   _ConcurrentStore__lock!_ConcurrentStore__pending_removes_ConcurrentStore__pending_adds)r   r)   s     r   r   ConcurrentStore.__init__   s.    
  f "$ r   c                     Uu  p#nU R                   S:X  a  U R                  R                  X#U45        g U R                  R	                  X#U45        g r(   )r*   r)   addr-   appendr   triplespos        r   r0   ConcurrentStore.add(   sE    	q"JJNNA!9%&&ay1r   c                     Uu  p#nU R                   S:X  a  U R                  R                  X#U45        g U R                  R	                  X#U45        g r(   )r*   r)   remover,   r1   r2   s        r   r9   ConcurrentStore.remove/   sG    	q"JJqQi(""))1)4r   c              #   Z  #    Uu  p#nU R                   R                  X#U45      nU R                  nU R                  5         [	        XPR
                  5       H  u  pxn	XxU	4U;  d  M  XxU	4v   M     U R                   H*  u  pxn	Ub  X':X  d  M  Ub  X8:X  d  M  Ub  XI:X  d  M$  XxU	4v   M,     g 7fr
   )r)   triplesr,   _ConcurrentStore__begin_readr   _ConcurrentStore__end_readr-   )
r   r3   suprobgpending_removesr4   r5   r6   s
             r   r<   ConcurrentStore.triples6   s     JJ|,00+A?GA!!9/Ag @ **GA!rwZ27Z27Ag +s   A B+&"B+B+B+ B+c                 6    U R                   R                  5       $ r
   )r)   __len__r   s    r   rF   ConcurrentStore.__len__G   s    zz!!##r   c                     U R                   nUR                  5         U R                  S-   U l        UR                  5         g )N   )r+   acquirer*   release)r   locks     r   __begin_readConcurrentStore.__begin_readJ   s0    {{!//!3r   c                    U R                   nUR                  5         U R                  S-
  U l        U R                  S:X  a  U R                  nU(       a:  UR	                  5       u  p4n U R
                  R                  X4U45        U(       a  M:  U R                  nU(       a9  UR	                  5       u  p4nU R
                  R                  X4U45        U(       a  M9  UR                  5         g !   [        X4US5         Nw= f)NrI   r   zNot in store to remove)r+   rJ   r*   r,   popr)   r9   printr-   r0   rK   )r   rL   rC   r4   r5   r6   pending_addss          r   
__end_readConcurrentStore.__end_readP   s    {{!//!3""44O!+//1	q=JJ%%qQi0 "/  ..L(,,.	q

ay) , 	=!#;<s   (C+ +C<)__lock__pending_adds__pending_removes__visit_countr)   N)r   r   r   r    r!   r   r0   r9   r<   rF   r=   r>   r#   r   r   r   r%   r%      s(    :!25"$r   r%   N)	threadingr   r   r%   r   r   r   <module>rZ      s     &J Jr   