9 #ifndef ZYPP_NG_THREAD_ASYNCQUEUE_H_INCLUDED 10 #define ZYPP_NG_THREAD_ASYNCQUEUE_H_INCLUDED 12 #include <zypp-core/zyppng/base/AbstractEventSource> 19 #include <condition_variable> 23 class AsyncQueueWatch;
42 template<
class Message >
47 using Ptr = std::shared_ptr<AsyncQueue>;
63 template<
typename T = Message >
72 template<
typename T = Message >
75 std::lock_guard lk(
_mut );
85 std::unique_lock<std::mutex> lk(
_mut );
86 _cv.wait( lk, [
this](){
return _messages.size() > 0; } );
97 std::lock_guard lk(
_mut );
143 std::condition_variable
_cv;
152 static std::shared_ptr<AsyncQueueWatch> create ( std::shared_ptr<AsyncQueueBase> queue );
155 void postNotifyEvent ();
160 void onFdReady(
int fd,
int events)
override;
161 void onSignal(
int signal)
override;
AsyncQueue & operator=(const AsyncQueue &)=delete
void removeWatch(AsyncQueueWatch &watch)
std::shared_ptr< AsyncQueue > Ptr
std::recursive_mutex _watchLock
std::optional< Message > tryPopUnlocked()
std::set< AsyncQueueWatch * > _watches
void addWatch(AsyncQueueWatch &watch)
virtual ~AsyncQueueBase()
void pushUnlocked(T &&value)
#define ZYPP_DECLARE_PRIVATE(Class)
std::queue< Message > _messages
#define LIBZYPP_NG_EXPORT
std::condition_variable _cv
std::optional< Message > tryPop()