try {
if (event != senf::Scheduler::EV_READ)
throw SystemException(EPIPE);
- std::string rcv (handle.read(maxSize_ - data_.size()));
+ std::string rcv;
+ handle.read(rcv, maxSize_ - data_.size());
data_.append(rcv);
std::string::size_type n = predicate_ ? (*predicate_)(data_) : std::string::npos;
if (n != std::string::npos || data_.size() >= maxSize_ || rcv.size() == 0) {
prefix_ senf::WriteHelper<Handle>::WriteHelper(Handle handle, std::string data,
Callback callback)
: handle_(handle), data_(data), callback_(callback),
- offset_(0), errno_(0)
+ offset_(data_.begin()), errno_(0)
{
senf::Scheduler::instance()
.add(handle_, boost::bind(&WriteHelper::dispatchProcess, ptr(this), _1, _2),
prefix_ std::string const & senf::WriteHelper<Handle>::data()
const
{
- if (offset_ > 0) {
- data_.erase(0,offset_);
- offset_ = 0;
+ if (offset_ > data_.begin()) {
+ data_.erase(data_.begin(),offset_);
+ offset_ = data_.begin();
}
return data_;
}
try {
if (event != senf::Scheduler::EV_WRITE)
throw senf::SystemException(EPIPE);
- offset_ += handle.write(data_.data()+offset_,data_.size()-offset_);
- if (offset_ >= data_.size()) {
+ offset_ = handle.write(std::make_pair(offset_,data_.end()));
+ if (offset_ == data_.end()) {
data_.erase();
+ offset_ = data_.begin();
complete_ = true;
}
}