mirror of
https://github.com/moparisthebest/spdylay
synced 2024-11-05 17:15:05 -05:00
Use bitmask instead of std::vector
This commit is contained in:
parent
6df709b441
commit
183cce1707
@ -30,7 +30,7 @@ namespace shrpx {
|
|||||||
|
|
||||||
IOControl::IOControl(bufferevent *bev)
|
IOControl::IOControl(bufferevent *bev)
|
||||||
: bev_(bev),
|
: bev_(bev),
|
||||||
ctrlv_(SHRPX_REASON_MAX)
|
rdbits_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
IOControl::~IOControl()
|
IOControl::~IOControl()
|
||||||
@ -43,14 +43,14 @@ void IOControl::set_bev(bufferevent *bev)
|
|||||||
|
|
||||||
void IOControl::pause_read(IOCtrlReason reason)
|
void IOControl::pause_read(IOCtrlReason reason)
|
||||||
{
|
{
|
||||||
ctrlv_[reason] = 1;
|
rdbits_ |= reason;
|
||||||
bufferevent_disable(bev_, EV_READ);
|
bufferevent_disable(bev_, EV_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IOControl::resume_read(IOCtrlReason reason)
|
bool IOControl::resume_read(IOCtrlReason reason)
|
||||||
{
|
{
|
||||||
ctrlv_[reason] = 0;
|
rdbits_ &= ~reason;
|
||||||
if(std::find(ctrlv_.begin(), ctrlv_.end(), 1) == ctrlv_.end()) {
|
if(rdbits_ == 0) {
|
||||||
bufferevent_enable(bev_, EV_READ);
|
bufferevent_enable(bev_, EV_READ);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -60,7 +60,7 @@ bool IOControl::resume_read(IOCtrlReason reason)
|
|||||||
|
|
||||||
void IOControl::force_resume_read()
|
void IOControl::force_resume_read()
|
||||||
{
|
{
|
||||||
std::fill(ctrlv_.begin(), ctrlv_.end(), 0);
|
rdbits_ = 0;
|
||||||
bufferevent_enable(bev_, EV_READ);
|
bufferevent_enable(bev_, EV_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,8 @@
|
|||||||
namespace shrpx {
|
namespace shrpx {
|
||||||
|
|
||||||
enum IOCtrlReason {
|
enum IOCtrlReason {
|
||||||
SHRPX_NO_BUFFER = 0,
|
SHRPX_NO_BUFFER = 1 << 0,
|
||||||
SHRPX_MSG_BLOCK,
|
SHRPX_MSG_BLOCK = 1 << 1
|
||||||
SHRPX_REASON_MAX
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class IOControl {
|
class IOControl {
|
||||||
@ -52,7 +51,7 @@ public:
|
|||||||
void force_resume_read();
|
void force_resume_read();
|
||||||
private:
|
private:
|
||||||
bufferevent *bev_;
|
bufferevent *bev_;
|
||||||
std::vector<int> ctrlv_;
|
uint32_t rdbits_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
Loading…
Reference in New Issue
Block a user