libzypp 17.34.1
providequeue_p.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14#ifndef ZYPP_MEDIA_PRIVATE_PROVIDE_QUEUE_P_H_INCLUDED
15#define ZYPP_MEDIA_PRIVATE_PROVIDE_QUEUE_P_H_INCLUDED
16
17#include "providefwd_p.h"
18#include "providemessage_p.h"
19#include <zypp-media/ng/Provide>
20#include <zypp-core/zyppng/io/Process>
21#include <zypp-core/ByteCount.h>
22
23#include <deque>
24#include <chrono>
25
26namespace zyppng {
27
28 class RpcMessageStream;
29 using RpcMessageStreamPtr = std::shared_ptr<RpcMessageStream>;
30
31 class ProvideQueue : public Base
32 {
33 public:
34 friend struct ProvideResourceData;
35
36 static constexpr uint32_t InvalidId = (uint32_t) -1;
38
39 using TimePoint = std::chrono::time_point<std::chrono::steady_clock>;
40
41 struct Item {
42
51 bool isAttachRequest () const;
52 bool isFileRequest () const;
53 bool isDetachRequest() const;
54
55 ProvideRequestRef _request;
56 };
57
60 bool startup ( const std::string &workerScheme, const zypp::Pathname &workDir, const std::string &hostname = "" );
61 void enqueue ( ProvideRequestRef request );
62 void cancel ( ProvideRequest *item, std::exception_ptr error );
63 void detach ( const std::string &id );
64 void scheduleNext ();
65 bool canScheduleMore () const;;
66 bool empty () const;
67
71 bool isIdle () const;
72
76 std::optional<TimePoint> idleSince () const;
77
81 uint requestCount () const;
82
86 uint activeRequests () const;
87
94
99 const std::string &hostname () const;
100
101 const Config &workerConfig () const;
102
103 SignalProxy<void()> sigIdle();
104
105 private:
106 bool doStartup ();
107 void processMessage ( );
108 void readAllStderr ();
109 void forwardToLog ( std::string &&logLine );
110 void processReadyRead( int channel );
111 void procFinished ( int exitCode );
112 uint32_t nextRequestId();
113
118 std::list< ProvideQueue::Item >::iterator dequeueActive ( std::list<Item>::iterator it );
119 void fatalWorkerError ( const std::exception_ptr &reason = nullptr );
120 void immediateShutdown ( const std::exception_ptr &reason );
121
125 std::list< ProvideQueue::Item >::iterator cancelActiveItem (std::list<Item>::iterator i, const std::exception_ptr &error );
126
127 private:
128 bool _queueShuttingDown = false;
129 uint8_t _crashCounter = 0;
132 std::string _myHostname;
134 std::deque< Item > _waitQueue;
135 std::list< Item > _activeItems;
139 std::optional<TimePoint> _idleSince;
140 };
141
142}
143
144#endif
Store and operate with byte count.
Definition ByteCount.h:32
WeakPtr parent() const
Definition base.cc:26
std::shared_ptr< Process > Ptr
Definition process.h:37
RpcMessageStreamPtr _messageStream
std::chrono::time_point< std::chrono::steady_clock > TimePoint
std::list< ProvideQueue::Item >::iterator cancelActiveItem(std::list< Item >::iterator i, const std::exception_ptr &error)
zypp::ByteCount expectedProvideSize() const
ProvideQueue(ProvidePrivate &parent)
void immediateShutdown(const std::exception_ptr &reason)
std::deque< Item > _waitQueue
void cancel(ProvideRequest *item, std::exception_ptr error)
uint requestCount() const
zypp::Pathname _currentExe
Signal< void()> _sigIdle
bool canScheduleMore() const
void processReadyRead(int channel)
const std::string & hostname() const
std::optional< TimePoint > _idleSince
ProvidePrivate & _parent
bool startup(const std::string &workerScheme, const zypp::Pathname &workDir, const std::string &hostname="")
const Config & workerConfig() const
std::optional< TimePoint > idleSince() const
void procFinished(int exitCode)
uint activeRequests() const
std::list< Item > _activeItems
void forwardToLog(std::string &&logLine)
void enqueue(ProvideRequestRef request)
SignalProxy< void()> sigIdle()
void detach(const std::string &id)
std::list< ProvideQueue::Item >::iterator dequeueActive(std::list< Item >::iterator it)
void fatalWorkerError(const std::exception_ptr &reason=nullptr)
static constexpr uint32_t InvalidId
std::shared_ptr< RpcMessageStream > RpcMessageStreamPtr
Definition provide_p.h:42
ProvideRequestRef _request