~scope() { if (cb_) { cb_(); } }
void RequestCallback::execute(int argc, char* argv[]) { if (!cb_) { return; } return cb_(request_id_, argc, argv); }
void AsyncIOOp::complete(ssize_t result) { DCHECK_EQ(state_, State::PENDING); state_ = State::COMPLETED; result_ = result; if (cb_) { cb_(this); } }
void const_buffer::tidy() { cb_(data_); // call provided deleter cb_ = saga::impl::not_owned_deleter; data_ = 0; size_ = -1; }
void Resolver::run_callback(int err, const Hosts* hosts) { remove_timer(); if(cb_) { cb_(err, hosts); cb_ = nullptr; } }
void AsyncHTTPRequester::done(CURLcode const rc) { TRACE("AsyncHTTPRequester::done"); CURLMcode mc = curl_multi_remove_handle(c_.multi_, easy_); mcode_or_throw("new_conn: curl_multi_add_handle", mc); cb_(rc, buf_.str()); ptr_to_this_.reset(); // Note: We keep the contents of the buffer until the next fetch call // or this object is destroyed. }
void Timer::update(float dt) { if (!isStarted_) return; elapsed_ += dt; if (elapsed_ > time_) { elapsed_ = 0; isStarted_ = !runOnce_; cb_(*this); } }
//! animates a scene node virtual void animateNode(ISceneNode* node, u32 timeMs) { if ( !node ) return; if ( timeMs < startTime_ ) return; u32 t = (timeMs-startTime_); T pos = start_; f32 dur = static_cast<f32>( duration_ ); if ( !loop_ && t >= duration_ ) { pos = Eq<T>::calculate(dur, pos, distance_, dur, node); Accessor::set(node, pos); if( cb_ ) cb_(); smgr_->addToAnimatorDeletionQueue(this, node); } else { f32 time = static_cast<f32>( t % duration_ ); pos = Eq<T>::calculate(time, pos, distance_, dur, node); Accessor::set(node, pos); } }
bool ShutdownNotifier::Impl::RegisterInterest(ShutdownCallback const& cb) { if (!cb or cb_) return false; cb_ = cb; Inhibit(); logind_proxy_->Connect("PrepareForShutdown", [this](GVariant* variant) { bool active = glib::Variant(variant).GetBool(); if (active) { cb_(); UnregisterInterest(); } }); return true; }
nsresult NrIceResolver::PendingResolution::OnLookupComplete( nsICancelable *request, nsIDNSRecord *record, nsresult status) { ASSERT_ON_THREAD(thread_); // First check if we've been canceled. This is single-threaded on the STS // thread, but cancel() cannot guarantee this event isn't on the queue. if (!canceled_) { nr_transport_addr *cb_addr = nullptr; nr_transport_addr ta; // TODO([email protected]): Revisit when we do TURN. if (NS_SUCCEEDED(status)) { net::NetAddr na; if (NS_SUCCEEDED(record->GetNextAddr(port_, &na))) { MOZ_ALWAYS_TRUE (nr_netaddr_to_transport_addr(&na, &ta) == 0); cb_addr = &ta; } } cb_(cb_arg_, cb_addr); Release(); } return NS_OK; }
void Mesher::prune_flags() { std::set<std::array<float, 6>> edges; for (auto t : triangles) { edges.insert(t.ab_()); edges.insert(t.bc_()); edges.insert(t.ca_()); } for (auto itr=triangles.begin(); itr != triangles.end(); ++itr) { if (!edges.count(itr->ba_()) || !edges.count(itr->cb_()) || !edges.count(itr->ac_())) { itr = triangles.erase(itr); itr--; } } }
void IrcClient::process_request(boost::asio::streambuf& buf) { std::istream is(&buf); is.unsetf(std::ios_base::skipws); std::string longreg(last_buf_); longreg.append(std::istream_iterator<char>(is), std::istream_iterator<char>()); #ifdef DEBUG std::cout << longreg; #endif size_t leave=longreg.rfind("\r\n")+2; if (leave!=longreg.length()) { last_buf_=longreg.substr(leave,longreg.length()-leave); longreg=longreg.substr(0,leave); }else last_buf_.clear(); std::vector<std::string> vec; boost::split(vec,longreg,boost::algorithm::is_any_of("\r\n"),boost::algorithm::token_compress_on); for (std::vector<std::string>::iterator it=vec.begin();it!=vec.end();it++) { std::string req=*it; if (req.substr(0,4)=="PING") { send_request("PONG "+req.substr(6,req.length()-8)); continue; } size_t pos=req.find(" PRIVMSG ")+1; if (!pos) continue; std::string msg=req; IrcMsg m; pos=msg.find("!")+1; if (!pos) continue; m.whom=msg.substr(1,pos-2); msg=msg.substr(pos); pos=msg.find(" PRIVMSG ")+1; if (!pos) continue; m.locate=msg.substr(0,pos-1); msg=msg.substr(pos); pos=msg.find("PRIVMSG ")+1; if (!pos) continue; msg=msg.substr(strlen("PRIVMSG ")); pos=msg.find(" ")+1; if (!pos) continue; m.from=msg.substr(0,pos-1); msg=msg.substr(pos); pos=msg.find(":")+1; if (!pos) continue; m.msg=msg.substr(pos,msg.length()-pos); cb_(m); } }
void operator()(int iter, double f, double gradNorm, const BasicLargeVector& v, const BasicLargeVector& g, const BasicLargeVector& z) { if(!cb_) return; cb_(iter, f, gradNorm, v.contents(), g.contents(), z.contents()); }
static aug_bool chandler_ready_(aug_chandler* ob, aug_chan* chan, unsigned short events) { return cb_(chan, events); }
void operator () (const ValueType& elem) const { cb_(elem); }
void free(ListNode* node) { // before uncache, we need to call the callback, such as write the data back to disk if (cb_) cb_(node->key, &node->value); node->next = free_; free_ = node; }
inline void callback(){if(cb_)cb_();}
void Run() { if (cb_) { cb_(0, 0, cb_arg_); } }
std::list<Vec3f> Mesher::get_contour() { // Find all of the singular edges in this fan // (edges that aren't shared between multiple triangles). std::set<std::array<float, 6>> valid_edges; for (auto itr=voxel_start; itr != voxel_end; ++itr) { if (valid_edges.count(itr->ba_())) valid_edges.erase(itr->ba_()); else valid_edges.insert(itr->ab_()); if (valid_edges.count(itr->cb_())) valid_edges.erase(itr->cb_()); else valid_edges.insert(itr->bc_()); if (valid_edges.count(itr->ac_())) valid_edges.erase(itr->ac_()); else valid_edges.insert(itr->ca_()); } std::set<std::array<float, 3>> in_fan; std::list<Vec3f> contour = {voxel_start->a}; in_fan.insert(voxel_start->a_()); in_fan.insert(voxel_start->b_()); in_fan.insert(voxel_start->c_()); fan_start = voxel_start; voxel_start++; while (contour.size() == 1 || contour.front() != contour.back()) { std::list<Triangle>::iterator itr; for (itr=fan_start; itr != voxel_end; ++itr) { const auto& t = *itr; if (contour.back() == t.a && valid_edges.count(t.ab_())) { contour.push_back(t.b); break; } if (contour.back() == t.b && valid_edges.count(t.bc_())) { contour.push_back(t.c); break; } if (contour.back() == t.c && valid_edges.count(t.ca_())) { contour.push_back(t.a); break; } } // If we broke out of the loop (meaning itr is pointing to a relevant // triangle which should be moved forward to before voxel_start), then // push the list around and update iterators appropriately. if (itr != voxel_end) { in_fan.insert(itr->a_()); in_fan.insert(itr->b_()); in_fan.insert(itr->c_()); if (itr == voxel_start) { voxel_start++; } else if (itr != fan_start) { const Triangle t = *itr; triangles.insert(voxel_start, t); itr = triangles.erase(itr); itr--; } } } // Special case to catch triangles that are part of a particular fan but // don't have any edges in the contour (which can happen!). for (auto itr=voxel_start; itr != voxel_end; ++itr) { if (in_fan.count(itr->a_()) && in_fan.count(itr->b_()) && in_fan.count(itr->c_())) { if (itr == voxel_start) { voxel_start++; } else if (itr != fan_start) { const Triangle t = *itr; triangles.insert(voxel_start, t); itr = triangles.erase(itr); itr--; } } } // Remove the last point of the contour, since it's a closed loop. contour.pop_back(); return contour; }