void RedisAsyncClient::command(const std::string &cmd, std::deque<RedisBuffer> args,
                          std::function<void(RedisValue)> handler)
{
    if(stateValid())
    {
        args.emplace_front(cmd);

        pimpl->post(std::bind(&RedisClientImpl::doAsyncCommand, pimpl,
                    std::move(pimpl->makeCommand(args)), std::move(handler)));
    }
}
Example #2
0
	void addMutationCandidate(const Sample<value_t> & sample,
							  const contribution_t & contribution,
							  ValuatedRegionNode * viewCell) {
		/*
		 * Insert new mutation candidates at the front because their mutation
		 * count is zero. Therefore, the array stays sorted.
		 */
		const bool useOrigin = (sample.getNumHits() < 2);
		if(std::get<0>(contribution) > 0) {
			const auto originPoint = useOrigin ? sample.getOrigin() :
												 sample.getBackwardTerminationPoint();
			Node * originObject = useOrigin ? static_cast<Node *>(viewCell) :
											  sample.getBackwardResult();
			const auto terminationPoint = sample.getForwardTerminationPoint();
			if(originPoint.distanceSquared(terminationPoint) > 1.0e-3) {
				mutationCandidates.emplace_front(originPoint,
												 originObject,
												 terminationPoint,
												 sample.getForwardResult());
			}
		}
		if(std::get<1>(contribution) > 0) {
			const auto originPoint = useOrigin ? sample.getOrigin() :
												 sample.getForwardTerminationPoint();
			Node * originObject = useOrigin ? static_cast<Node *>(viewCell) :
											  sample.getForwardResult();
			const auto terminationPoint = sample.getBackwardTerminationPoint();
			if(originPoint.distanceSquared(terminationPoint) > 1.0e-3) {
				mutationCandidates.emplace_front(originPoint,
												 originObject,
												 terminationPoint,
												 sample.getBackwardResult());
			}
		}
		// Constant suggested in the article
		const uint32_t maxNumMutationCandidates = 2000000;
		while(mutationCandidates.size() > maxNumMutationCandidates) {
			mutationCandidates.pop_back();
		}
	}
 result_type
 traverse(std::conditional_t< reassmble, ast::expression &&, ast::expression const & > _input)
 { // if reassmble is true, then input is taken apart, then reassembled
     assert(output_.empty());
     if (_input.rest_.empty()) {
         return dispatcher_(std::move(_input.first_));
     } else if (_input.rest_.size() == 1) {
         auto & operation_ = _input.rest_.back();
         return dispatcher_(std::move(_input.first_),
                            operation_.operator_,
                            std::move(operation_.operand_));
     } else {
         //output_.reserve(_input.rest_.size() * 2 + 1); // total number of operators and operands
         std::stack< aggregate_wrapper< lhs_op > > lhs_op_;
         for (auto & operation_ : _input.rest_) {
             size_type const precedence_ = ast::precedence(operation_.operator_);
             while (!lhs_op_.empty()) {
                 lhs_op const & top_ = lhs_op_.top();
                 if (ast::precedence(top_.operator_) < precedence_) {
                     break;
                 }
                 output_.emplace_back(top_.lhs_, top_.operator_, output_.size());
                 lhs_op_.pop();
             }
             lhs_op_.emplace(output_.size(), operation_.operator_);
             output_.emplace_back(&operation_.operand_);
         }
         while (!lhs_op_.empty()) {
             lhs_op const & top_ = lhs_op_.top();
             output_.emplace_back(top_.lhs_, top_.operator_, output_.size());
             lhs_op_.pop();
         }
         output_.emplace_front(&_input.first_);
         return operator () (output_.back());
     }
 }
Example #4
0
 void enqueue_front(IoRef &&io) {
     queue.emplace_front(std::move(io));
 }
Example #5
0
 void push(task&& t)
 {
     std::lock_guard<mutex_type> l(_mutex);
     _tasks.emplace_front(std::move(t));
 }
void bad_emplace_front_deque1(std::deque<int> &D, int n) {
  auto i0 = D.cbegin(), i1 = D.cend();
  D.emplace_front(n);
  *i0; // expected-warning{{Invalidated iterator accessed}}
  --i1; // expected-warning{{Invalidated iterator accessed}}
}