@@ -125,3 +125,31 @@ def __init__(self, _func: Callable[_TParams, _TResult]) -> None:
125125class event (EventDescriptorBase [_TParams , _TResult , Event [_TParams , _TResult ]]): # noqa: N801
126126 def __init__ (self , _func : Callable [_TParams , _TResult ]) -> None :
127127 super ().__init__ (_func , Event [_TParams , _TResult ])
128+
129+
130+ class ThreadedEventResultIteratorBase (EventResultIteratorBase [_TParams , _TResult ]):
131+ def _notify (self , * __args : _TParams .args , ** __kwargs : _TParams .kwargs ) -> Iterator [_TResult ]:
132+ for method in set (self ):
133+ yield method (* __args , ** __kwargs )
134+
135+
136+ class ThreadedEventIterator (ThreadedEventResultIteratorBase [_TParams , _TResult ]):
137+ def __call__ (self , * __args : _TParams .args , ** __kwargs : _TParams .kwargs ) -> Iterator [_TResult ]:
138+ return self ._notify (* __args , ** __kwargs )
139+
140+
141+ class ThreadedEvent (ThreadedEventResultIteratorBase [_TParams , _TResult ]):
142+ def __call__ (self , * __args : _TParams .args , ** __kwargs : _TParams .kwargs ) -> List [_TResult ]:
143+ return list (self ._notify (* __args , ** __kwargs ))
144+
145+
146+ class threaded_event_iterator ( # noqa: N801
147+ EventDescriptorBase [_TParams , _TResult , ThreadedEventIterator [_TParams , _TResult ]]
148+ ):
149+ def __init__ (self , _func : Callable [_TParams , _TResult ]) -> None :
150+ super ().__init__ (_func , ThreadedEventIterator [_TParams , _TResult ])
151+
152+
153+ class threaded_event (EventDescriptorBase [_TParams , _TResult , ThreadedEvent [_TParams , _TResult ]]): # noqa: N801
154+ def __init__ (self , _func : Callable [_TParams , _TResult ]) -> None :
155+ super ().__init__ (_func , ThreadedEvent [_TParams , _TResult ])
0 commit comments