Пример #1
0
// Outputs derivatives (DRbar scheme) in the form of ds
StandardModel<Two_scale> StandardModel<Two_scale>::calc_beta() const
{
   static const double oneO16Pisq = 1.0 / (16.0 * PI * PI);
   DoubleMatrix dyu(3, 3), dyd(3, 3), dye(3, 3);
   DoubleVector dg(3);

   dyu(3, 3) = oneO16Pisq * yu.display(3, 3) * (
      -17.0 / 20.0 * sqr(displayGaugeCoupling(1))
      - 9.0 / 4.0 * sqr(displayGaugeCoupling(2))
      - 8.0 * sqr(displayGaugeCoupling(3))
      + 4.5 * sqr(yu.display(3, 3))
      + 1.5 * sqr(yd.display(3, 3))
      + sqr(ye.display(3, 3)));

   dyd(3, 3) = oneO16Pisq * yd.display(3, 3) * (
      -0.25 * sqr(displayGaugeCoupling(1))
      - 9.0 / 4.0 * sqr(displayGaugeCoupling(2))
      - 8.0 * sqr(displayGaugeCoupling(3))
      + 1.5 * sqr(yu.display(3, 3))
      + 4.5 * sqr(yd.display(3, 3))
      + sqr(ye.display(3, 3)));

   dye(3, 3) = oneO16Pisq * ye.display(3, 3) * (
      -9.0 / 4.0 * sqr(displayGaugeCoupling(1))
      -9.0 / 4.0 * sqr(displayGaugeCoupling(2))
      + 3.0 * sqr(yu.display(3, 3))
      + 3.0 * sqr(yd.display(3, 3))
      + 2.5 * sqr(ye.display(3, 3)));

   dg(1) = oneO16Pisq * std::pow(displayGaugeCoupling(1), 3) * (41.0 / 10.0);
   dg(2) = oneO16Pisq * std::pow(displayGaugeCoupling(2), 3) * (-19.0 / 6.0);
   dg(3) = oneO16Pisq * std::pow(displayGaugeCoupling(3), 3) * (-7.0);

   return StandardModel(dyu, dyd, dye, dg);
}
Пример #2
0
HTTPTransaction*
HTTPUpstreamSession::newTransaction(HTTPTransaction::Handler* handler,
                                    int8_t priority) {
  CHECK_NOTNULL(handler);

  if (!supportsMoreTransactions() || draining_) {
    // This session doesn't support any more parallel transactions
    return nullptr;
  }

  if (!started_) {
    startNow();
  }

  auto txn = createTransaction(codec_->createStream(),
                               0,
                               priority);

  if (txn) {
    DestructorGuard dg(this);
    auto txnID = txn->getID();
    txn->setHandler(handler);
    setNewTransactionPauseState(txnID);
  }
  return txn;
}
Пример #3
0
Файл: File.cpp Проект: Ilia/xbmc
 unsigned long File::read(void* buffer, unsigned long numBytes)
 {
   DelayedCallGuard dg(languageHook);
   if (!numBytes)
     numBytes = (unsigned long)file->GetLength();
   return (unsigned long)file->Read(buffer, numBytes);
 }
Пример #4
0
void HeaderServerChannel::sendCatchupRequests(
    std::unique_ptr<folly::IOBuf> next_req,
    MessageChannel::SendCallback* cb,
    std::vector<uint16_t> transforms) {

  DestructorGuard dg(this);

  while (true) {
    if (next_req) {
      try {
        header_->setSequenceNumber(lastWrittenSeqId_ + 1);
        header_->setTransforms(transforms);
        sendMessage(cb, std::move(next_req));
      } catch (const std::exception& e) {
        LOG(ERROR) << "Failed to send message: " << e.what();
      }
    } else if (nullptr != cb) {
      // There is no message (like a oneway req), but there is a callback
      cb->messageSent();
    }
    lastWrittenSeqId_++;

    // Check for the next req
    auto next = inOrderRequests_.find(
        lastWrittenSeqId_ + 1);
    if (next != inOrderRequests_.end()) {
      next_req = std::move(std::get<1>(next->second));
      cb = std::get<0>(next->second);
      transforms = std::get<2>(next->second);
      inOrderRequests_.erase(lastWrittenSeqId_ + 1);
    } else {
      break;
    }
  }
}
Пример #5
0
// Print the cells of the W-graph of the block.
void wcells_f()
{
  const wgraph::WGraph& wg = currentWGraph();
  wgraph::DecomposedWGraph dg(wg);

  ioutils::OutputFile file; wgraph_io::printWDecomposition(file,dg);
}
Пример #6
0
 void InternalConnection::unsubscribe_range(channel_t lo, channel_t hi)
 {
     Datagram dg(CONTROL_REMOVE_RANGE);
     dg.add_channel(lo);
     dg.add_channel(hi);
     send_datagram(dg);
 }
Пример #7
0
void TZlibAsyncChannel::recvMessage(const VoidCallback& callback,
                                    const VoidCallback& errorCallback,
                                    TMemoryBuffer* message) {
  assert(message);
  DestructorGuard dg(this);

  if (!good()) {
    T_DEBUG_T("zlib channel: attempted to read on non-good channel");
    return errorCallback();
  }

  if (recvRequest_.isSet()) {
    T_ERROR("zlib async channel is already reading");
    return errorCallback();
  }

  try {
    recvRequest_.set(callback, errorCallback, message);
  } catch (const std::exception& ex) {
    T_ERROR("zlib async channel: error initializing receive: %s", ex.what());
    return errorCallback();
  }

  recvRequest_.recv(channel_.get());
}
Пример #8
0
void McServerSession::readDataAvailable(size_t len) noexcept {
  DestructorGuard dg(this);

  if (!parser_.readDataAvailable(len)) {
    close();
  }
}
Пример #9
0
void TZlibAsyncChannel::sendMessage(const VoidCallback& callback,
                                    const VoidCallback& errorCallback,
                                    TMemoryBuffer* message) {
  assert(message);
  DestructorGuard dg(this);

  if (!good()) {
    T_DEBUG_T("zlib channel: attempted to send on non-good channel");
    return errorCallback();
  }

  if (sendRequest_.isSet()) {
    T_ERROR("zlib async channel currently does not support multiple "
            "outstanding send requests");
    return errorCallback();
  }

  try {
    sendRequest_.set(callback, errorCallback, message);
  } catch (const std::exception& ex) {
    T_ERROR("zlib async channel: error initializing send: %s", ex.what());
    return errorCallback();
  }

  sendRequest_.send(channel_.get());
}
Пример #10
0
void McServerSession::writeError(
  size_t bytesWritten,
  const apache::thrift::transport::TTransportException& ex) noexcept {

  DestructorGuard dg(this);
  completeWrite();
}
Пример #11
0
void AsyncMcClientImpl::pushMessages() {
  DestructorGuard dg(this);

  assert(connectionState_ == ConnectionState::UP);
  size_t numToSend = queue_.getPendingRequestCount();
  if (maxInflight_ != 0) {
    if (maxInflight_ <= getInflightRequestCount()) {
      numToSend = 0;
    } else {
      numToSend = std::min(numToSend,
                           maxInflight_ - getInflightRequestCount());
    }
  }
  // Record current batch size.
  batchStatCurrent.first += numToSend;
  ++batchStatCurrent.second;
  if (batchStatCurrent.second == kBatchSizeStatWindow) {
    batchStatPrevious = batchStatCurrent;
    batchStatCurrent = {0, 0};
  }

  while (getPendingRequestCount() != 0 && numToSend > 0 &&
         /* we might be already not UP, because of failed writev */
         connectionState_ == ConnectionState::UP) {
    auto& req = queue_.markNextAsSending();

    socket_->writev(this, req.reqContext.getIovs(),
                    req.reqContext.getIovsCount(),
                    numToSend == 1 ? folly::WriteFlags::NONE
                    : folly::WriteFlags::CORK);
    --numToSend;
  }
  writeScheduled_ = false;
  scheduleNextWriterLoop();
}
Пример #12
0
 DiGraph DiGraph::reverse() const {
     DiGraph dg(V());
     for(int v=0;v<V();++v)
         for(int w : adjacent(v))
             dg.addEdge(w,v);
     return dg;
 }
Пример #13
0
void AsyncMcClientImpl::connectErr(
    const folly::AsyncSocketException& ex) noexcept {
  assert(connectionState_ == ConnectionState::CONNECTING);
  DestructorGuard dg(this);

  mc_res_t error;

  if (ex.getType() == folly::AsyncSocketException::TIMED_OUT) {
    error = mc_res_connect_timeout;
  } else if (isAborting_) {
    error = mc_res_aborted;
  } else {
    error = mc_res_connect_error;
  }

  assert(getInflightRequestCount() == 0);
  queue_.failAllPending(error);
  connectionState_ = ConnectionState::DOWN;
  // We don't need it anymore, so let it perform complete cleanup.
  socket_.reset();

  if (statusCallbacks_.onDown) {
    statusCallbacks_.onDown(isAborting_);
  }
}
Пример #14
0
void TestExprDiff::apply02() {
	Variable x("x");
	Function f(x,sqr(x),"f");
	Function g(x,3*f(x));
	Function dg(g,Function::DIFF);
	TEST_ASSERT(sameExpr(dg.expr(),"(df(x)*3)"));
}
Пример #15
0
    XbmcCommons::Buffer File::readBytes(unsigned long numBytes)
    {
      DelayedCallGuard dg(languageHook);
      int64_t size = file->GetLength();
      if (!numBytes || (((int64_t)numBytes) > size))
        numBytes = (unsigned long) size;

      
      XbmcCommons::Buffer ret(numBytes);

      if (numBytes == 0)
        return ret;

      while(ret.remaining() > 0)
      {
        int bytesRead = file->Read(ret.curPosition(), ret.remaining());
        if (bytesRead == 0) // we consider this a failure or a EOF, can't tell which,
        {                   //  return whatever we have already.
          ret.flip();
          return ret;
        }
        ret.forward(bytesRead);
      }
      ret.flip();
      return ret;
    }
Пример #16
0
GameList QueenMetaEngine::detectGames(const Common::FSList &fslist) const {
	GameList detectedGames;

	// Iterate over all files in the given directory
	for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
		if (file->isDirectory()) {
			continue;
		}
		if (file->getName().equalsIgnoreCase("queen.1") || file->getName().equalsIgnoreCase("queen.1c")) {
			Common::File dataFile;
			if (!dataFile.open(*file)) {
				continue;
			}
			Queen::DetectedGameVersion version;
			if (Queen::Resource::detectVersion(&version, &dataFile)) {
				GameDescriptor dg(queenGameDescriptor.gameid, queenGameDescriptor.description, version.language, version.platform);
				if (version.features & Queen::GF_DEMO) {
					dg.updateDesc("Demo");
					dg.setGUIOptions(Common::GUIO_NOSPEECH);
				} else if (version.features & Queen::GF_INTERVIEW) {
					dg.updateDesc("Interview");
					dg.setGUIOptions(Common::GUIO_NOSPEECH);
				} else if (version.features & Queen::GF_FLOPPY) {
					dg.updateDesc("Floppy");
					dg.setGUIOptions(Common::GUIO_NOSPEECH);
				} else if (version.features & Queen::GF_TALKIE) {
					dg.updateDesc("Talkie");
				}
				detectedGames.push_back(dg);
				break;
			}
		}
	}
	return detectedGames;
}
Пример #17
0
void McServerSession::writeSuccess() noexcept {
  DestructorGuard dg(this);
  completeWrite();

  /* No-op if not paused */
  resume(PAUSE_WRITE);
}
Пример #18
0
void McServerSession::queueWrite(
  std::unique_ptr<McServerTransaction> ptransaction) {
  DestructorGuard dg(this);

  if (ptransaction->noReply()) {
    return;
  }

  /* TODO: the subrequests should simply add to the parent's request
     iovs, so that we only write once */
  ptransaction->queueSubRequestsWrites();
  auto& transaction = pendingWrites_.pushBack(std::move(ptransaction));
  if (options_.singleWrite) {
    if (!transaction.prepareWrite()) {
      transport_->close();
      return;
    }

    transport_->writev(this, transaction.iovs_, transaction.niovs_);
    if (!pendingWrites_.empty()) {
      /* We only need to pause if the sendmsg() call didn't write everything
         in one go */
      pause(PAUSE_WRITE);
    }
  } else {
    if (!writeScheduled_) {
      auto eventBase = transport_->getEventBase();
      CHECK(eventBase != nullptr);
      eventBase->runInLoop(&sendWritesCallback_, /* thisIteration= */ true);
      writeScheduled_ = true;
    }
  }
}
Пример #19
0
// Client Interface
uint32_t HTTPClientChannel::sendOnewayRequest(
    RpcOptions& rpcOptions,
    std::unique_ptr<RequestCallback> cb,
    std::unique_ptr<apache::thrift::ContextStack> ctx,
    unique_ptr<IOBuf> buf,
    std::shared_ptr<THeader> header) {
  DestructorGuard dg(this);
  cb->context_ = RequestContext::saveContext();

  HTTPTransactionOnewayCallback* owcb = nullptr;

  if (cb) {
    owcb = new HTTPTransactionOnewayCallback(
        std::move(cb), std::move(ctx), isSecurityActive());
  }

  if (!httpSession_) {
    if (owcb) {
      TTransportException ex(TTransportException::NOT_OPEN,
                             "HTTPSession is not open");
      owcb->messageSendError(
          folly::make_exception_wrapper<TTransportException>(std::move(ex)));

      delete owcb;
    }

    return -1;
  }

  auto txn = httpSession_->newTransaction(owcb);

  if (!txn) {
    if (owcb) {
      TTransportException ex(TTransportException::NOT_OPEN,
                             "Too many active requests on connection");
      owcb->messageSendError(
          folly::make_exception_wrapper<TTransportException>(std::move(ex)));

      delete owcb;
    }

    return -1;
  }

  setRequestHeaderOptions(header.get());
  addRpcOptionHeaders(header.get(), rpcOptions);

  auto msg = buildHTTPMessage(header.get());

  txn->sendHeaders(msg);
  txn->sendBody(std::move(buf));
  txn->sendEOM();

  if (owcb) {
    owcb->sendQueued();
  }

  return ResponseChannel::ONEWAY_REQUEST_ID;
}
Пример #20
0
void McServerSession::requestReady(McRequest req,
                                   mc_op_t operation,
                                   uint64_t reqid,
                                   mc_res_t result,
                                   bool noreply) {
  DestructorGuard dg(this);

  auto sharedThis = weakThis_.lock();
  if (!sharedThis) {
    /* This session is being destroyed, can't create new transactions */
    close();
    return;
  }

  if (state_ != STREAMING) {
    return;
  }

  auto isSubRequest = isPartOfMultiget(parser_.protocol(), operation);
  auto isMultiget = (operation == mc_op_end);
  auto transactionPtr =
    folly::make_unique<McServerTransaction>(
      sharedThis,
      std::move(req),
      operation,
      reqid,
      isMultiget,
      isSubRequest,
      noreply);
  McServerTransaction& transaction = [&]() -> McServerTransaction& {
    if (isSubRequest) {
      return multigetRequests_.pushBack(std::move(transactionPtr));
    } else {
      return unansweredRequests_.pushBack(std::move(transactionPtr));
    }
  }();

  if (result == mc_res_bad_key) {
    transaction.sendReply(McReply(mc_res_bad_key));
  } else if (operation == mc_op_version) {
    transaction.sendReply(McReply(mc_res_ok, options_.versionString));
  } else if (operation == mc_op_quit) {
    /* mc_op_quit transaction will have `noreply` set, so this call
       is solely to make sure the transaction is completed and cleaned up */
    transaction.sendReply(McReply(mc_res_ok));
    close();
  } else if (operation == mc_op_shutdown) {
    transaction.sendReply(McReply(mc_res_ok));
    onShutdown_();
  } else if (isMultiget) {
    while (!multigetRequests_.empty()) {
      auto subReq = multigetRequests_.popFront();
      transaction.pushMultigetRequest(std::move(subReq));
    }
    transaction.dispatchSubRequests(*onRequest_);
  } else if (!isSubRequest) {
    transaction.dispatchRequest(*onRequest_);
  }
}
Пример #21
0
 void Window::removeControls(std::vector<Control*> pControls)
 {
   XBMC_TRACE;
   DelayedCallGuard dg(languageHook);
   int count = 1; int size = pControls.size();
   for (std::vector<Control*>::iterator iter = pControls.begin(); iter != pControls.end(); count++, ++iter)
     doRemoveControl(*iter,NULL, count == size);
 }
Пример #22
0
void AsyncMcClientImpl::parseError(mc_res_t result, folly::StringPiece reason) {
  // mc_parser can call the parseError multiple times, process only first.
  if (connectionState_ != ConnectionState::UP) {
    return;
  }
  DestructorGuard dg(this);
  processShutdown();
}
Пример #23
0
void Cpp2Channel::readException(Context* ctx, folly::exception_wrapper e)  {
  DestructorGuard dg(this);
  VLOG(5) << "Got a read error: " << folly::exceptionStr(e);
  if (recvCallback_) {
    recvCallback_->messageReceiveErrorWrapped(std::move(e));
  }
  processReadEOF();
}
Пример #24
0
void TestExprDiff::apply01() {
	Variable x("x");
	Function f(x,sqr(x),"f");
	Function g(x,f(3*x));
	Function dg(g,Function::DIFF);
	TEST_ASSERT(sameExpr(f.diff().expr(),"(2*x)"));
	TEST_ASSERT(sameExpr(dg.expr(),"(3*df((3*x)))"));
}
Пример #25
0
void Cpp2Channel::readError(const TTransportException & ex) noexcept {
  DestructorGuard dg(this);
  VLOG(5) << "Got a read error: " << folly::exceptionStr(ex);
  if (recvCallback_) {
    recvCallback_->messageReceiveError(make_exception_ptr(ex));
  }
  processReadEOF();
}
Пример #26
0
 void Window::addControls(std::vector<Control*> pControls) throw (WindowException)
 {
   TRACE;
   DelayedCallGuard dg(languageHook);
   CSingleLock lock(g_graphicsContext);
   int count = 1; int size = pControls.size();
   for (std::vector<Control*>::iterator iter = pControls.begin(); iter != pControls.end(); count++, iter++)
     doAddControl(*iter,NULL, count == size);
 }
Пример #27
0
void Cpp2Channel::closeNow() {
  // closeNow can invoke callbacks
  DestructorGuard dg(this);
  closing_ = true;
  transport_->setReadCallback(NULL);
  transport_->closeNow();

  processReadEOF(); // Call failure callbacks
}
Пример #28
0
 void Keyboard::doModal(int autoclose)
 {
   DelayedCallGuard dg(languageHook);
   // using keyboardfactory method to get native keyboard if there is.
   strText = strDefault;
   CStdString text(strDefault);
   bConfirmed = CGUIKeyboardFactory::ShowAndGetInput(text, strHeading, true, bHidden, autoclose * 1000);
   strText = text;
 }
Пример #29
0
void Cpp2Channel::writeSuccess() noexcept {
  assert(sendCallbacks_.size() > 0);

  DestructorGuard dg(this);
  for (auto& cb : sendCallbacks_.front()) {
    cb->messageSent();
  }
  sendCallbacks_.pop_front();
}
Пример #30
0
 static void dg(ClassDeclaration *cd, Identifiers *idents)
 {
     for (size_t i = 0; i < cd->baseclasses->dim; i++)
     {   ClassDeclaration *cb = (*cd->baseclasses)[i]->base;
         ScopeDsymbol::foreach(NULL, cb->members, &PushIdentsDg::dg, idents);
         if (cb->baseclasses->dim)
             dg(cb, idents);
     }
 }