예제 #1
0
// This Benchmark tests the CheckQueue with a slightly realistic workload, where
// checks all contain a prevector that is indirect 50% of the time and there is
// a little bit of work done between calls to Add.
static void CCheckQueueSpeedPrevectorJob(benchmark::State &state) {
    struct PrevectorJob {
        prevector<PREVECTOR_SIZE, uint8_t> p;
        PrevectorJob() {}
        PrevectorJob(FastRandomContext &insecure_rand) {
            p.resize(insecure_rand.randrange(PREVECTOR_SIZE * 2));
        }
        bool operator()() { return true; }
        void swap(PrevectorJob &x) { p.swap(x.p); };
    };
    CCheckQueue<PrevectorJob> queue{QUEUE_BATCH_SIZE};
    boost::thread_group tg;
    for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) {
        tg.create_thread([&] { queue.Thread(); });
    }
    while (state.KeepRunning()) {
        // Make insecure_rand here so that each iteration is identical.
        FastRandomContext insecure_rand(true);
        CCheckQueueControl<PrevectorJob> control(&queue);
        std::vector<std::vector<PrevectorJob>> vBatches(BATCHES);
        for (auto &vChecks : vBatches) {
            vChecks.reserve(BATCH_SIZE);
            for (size_t x = 0; x < BATCH_SIZE; ++x)
                vChecks.emplace_back(insecure_rand);
            control.Add(vChecks);
        }
        // control waits for completion by RAII, but it is done explicitly here
        // for clarity
        control.Wait();
    }
    tg.interrupt_all();
    tg.join_all();
}
예제 #2
0
static void CCheckQueueSpeed(benchmark::State &state) {
    struct FakeJobNoWork {
        bool operator()() { return true; }
        void swap(FakeJobNoWork &x){};
    };
    CCheckQueue<FakeJobNoWork> queue{QUEUE_BATCH_SIZE};
    boost::thread_group tg;
    for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) {
        tg.create_thread([&] { queue.Thread(); });
    }
    while (state.KeepRunning()) {
        CCheckQueueControl<FakeJobNoWork> control(&queue);

        // We call Add a number of times to simulate the behavior of adding a
        // block of transactions at once.
        std::vector<std::vector<FakeJobNoWork>> vBatches(BATCHES);
        for (auto &vChecks : vBatches) {
            vChecks.resize(BATCH_SIZE);
        }

        for (auto &vChecks : vBatches) {
            // We can't make vChecks in the inner loop because we want to
            // measure the cost of getting the memory to each thread and we
            // might get the same memory
            control.Add(vChecks);
        }
        // control waits for completion by RAII, but it is done explicitly here
        // for clarity
        control.Wait();
    }
    tg.interrupt_all();
    tg.join_all();
}
예제 #3
0
파일: cgroup.cpp 프로젝트: noxiouz/porto
// Cpu
void TCpuSubsystem::InitializeSubsystem() {
    TCgroup cg = RootCgroup();

    HasShares = cg.Has("cpu.shares");
    if (HasShares && cg.GetUint64("cpu.shares", BaseShares))
        BaseShares = 1024;

    HasQuota = cg.Has("cpu.cfs_quota_us") &&
               cg.Has("cpu.cfs_period_us");

    HasReserve = HasShares && HasQuota &&
                 cg.Has("cpu.cfs_reserve_us") &&
                 cg.Has("cpu.cfs_reserve_shares");

    if (HasQuota && cg.GetUint64("cpu.cfs_period_us", BasePeriod))
        BasePeriod = 100000;

    HasSmart = cg.Has("cpu.smart");

    L_SYS() << GetNumCores() << " cores" << std::endl;
    if (HasShares)
        L_SYS() << "base shares " << BaseShares << std::endl;
    if (HasQuota)
        L_SYS() << "quota period " << BasePeriod << std::endl;
    if (HasReserve)
        L_SYS() << "support reserves" << std::endl;
    if (HasSmart)
        L_SYS() << "support smart" << std::endl;
}
예제 #4
0
OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
    QDialog(parent),
    ui(new Ui::OptionsDialog),
    model(0),
    mapper(0),
    fProxyIpsValid(true)
{
    ui->setupUi(this);

    /* Main elements init */
    ui->databaseCache->setMinimum(nMinDbCache);
    ui->databaseCache->setMaximum(nMaxDbCache);
    ui->threadsScriptVerif->setMinimum(-GetNumCores());
    ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);

    /* Network elements init */
#ifndef USE_UPNP
    ui->mapPortUpnp->setEnabled(false);
#endif

    ui->proxyIp->setEnabled(false);
    ui->proxyPort->setEnabled(false);
    ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));

    ui->proxyIpTor->setEnabled(false);
    ui->proxyPortTor->setEnabled(false);
    ui->proxyPortTor->setValidator(new QIntValidator(1, 65535, this));

    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));

    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyIpTor, SLOT(setEnabled(bool)));
    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyPortTor, SLOT(setEnabled(bool)));

    ui->proxyIp->installEventFilter(this);
    ui->proxyIpTor->installEventFilter(this);

    /* Window elements init */
#ifdef Q_OS_MAC
    /* remove Window tab on Mac */
    ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
#endif

    /* remove Wallet tab in case of -disablewallet */
    if (!enableWallet) {
        ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWallet));
    }

    /* Display elements init */
    QDir translations(":translations");
    ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
    Q_FOREACH(const QString &langStr, translations.entryList())
    {
        QLocale locale(langStr);

        /** check if the locale name consists of 2 parts (language_country) */
        if(langStr.contains("_"))
        {
#if QT_VERSION >= 0x040800
            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
            /** display language strings as "language - country (locale name)", e.g. "German - Germany (de)" */
            ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" - ") + QLocale::countryToString(locale.country()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
        }
        else
        {
#if QT_VERSION >= 0x040800
            /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
            /** display language strings as "language (locale name)", e.g. "German (de)" */
            ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
        }
    }
#if QT_VERSION >= 0x040700
    ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s");
#endif

    ui->unit->setModel(new BeCoinUnits(this));

    /* Widget-to-option mapper */
    mapper = new QDataWidgetMapper(this);
    mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    mapper->setOrientation(Qt::Vertical);

    /* setup/change UI elements when proxy IPs are invalid/valid */
    connect(this, SIGNAL(proxyIpChecks(QValidatedLineEdit *, int)), this, SLOT(doProxyIpChecks(QValidatedLineEdit *, int)));
}
예제 #5
0
OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
    QDialog(parent),
    ui(new Ui::OptionsDialog),
    model(0),
    mapper(0)
{
    ui->setupUi(this);

    /* Main elements init */
    ui->databaseCache->setMinimum(nMinDbCache);
    ui->databaseCache->setMaximum(nMaxDbCache);
    static const uint64_t GiB = 1024 * 1024 * 1024;
    static const uint64_t nMinDiskSpace = MIN_DISK_SPACE_FOR_BLOCK_FILES / GiB +
                          (MIN_DISK_SPACE_FOR_BLOCK_FILES % GiB) ? 1 : 0;
    ui->pruneSize->setMinimum(nMinDiskSpace);
    ui->threadsScriptVerif->setMinimum(-GetNumCores());
    ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
    ui->pruneWarning->setVisible(false);
    ui->pruneWarning->setStyleSheet("QLabel { color: red; }");

    ui->pruneSize->setEnabled(false);
    connect(ui->prune, SIGNAL(toggled(bool)), ui->pruneSize, SLOT(setEnabled(bool)));

    /* Network elements init */
#ifndef USE_UPNP
    ui->mapPortUpnp->setEnabled(false);
#endif

    ui->proxyIp->setEnabled(false);
    ui->proxyPort->setEnabled(false);
    ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));

    ui->proxyIpTor->setEnabled(false);
    ui->proxyPortTor->setEnabled(false);
    ui->proxyPortTor->setValidator(new QIntValidator(1, 65535, this));

    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(toggled(bool)), this, SLOT(updateProxyValidationState()));

    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyIpTor, SLOT(setEnabled(bool)));
    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyPortTor, SLOT(setEnabled(bool)));
    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), this, SLOT(updateProxyValidationState()));

    /* Window elements init */
#ifdef Q_OS_MAC
    /* remove Window tab on Mac */
    ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
#endif

    /* remove Wallet tab in case of -disablewallet */
    if (!enableWallet) {
        ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWallet));
    }

    /* Display elements init */


    /* Theme selector */

    ui->theme->addItem(QString("DGB-Black"), QVariant("black"));
    ui->theme->addItem(QString("DGB-Blue"), QVariant("blue"));
    ui->theme->addItem(QString("DGB-White"), QVariant("white"));
 


    QDir translations(":translations");

    ui->digibyteAtStartup->setToolTip(ui->digibyteAtStartup->toolTip().arg(tr(PACKAGE_NAME)));
    ui->digibyteAtStartup->setText(ui->digibyteAtStartup->text().arg(tr(PACKAGE_NAME)));

    ui->openDigiByteConfButton->setToolTip(ui->openDigiByteConfButton->toolTip().arg(tr(PACKAGE_NAME)));

    ui->lang->setToolTip(ui->lang->toolTip().arg(tr(PACKAGE_NAME)));
    ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
    for (const QString &langStr : translations.entryList())
    {
        QLocale locale(langStr);

        /** check if the locale name consists of 2 parts (language_country) */
        if(langStr.contains("_"))
        {
            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
        }
        else
        {
            /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
        }
    }
    ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s");

    ui->unit->setModel(new DigiByteUnits(this));

    /* Widget-to-option mapper */
    mapper = new QDataWidgetMapper(this);
    mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    mapper->setOrientation(Qt::Vertical);

    GUIUtil::ItemDelegate* delegate = new GUIUtil::ItemDelegate(mapper);
    connect(delegate, &GUIUtil::ItemDelegate::keyEscapePressed, this, &OptionsDialog::reject);
    mapper->setItemDelegate(delegate);

    /* setup/change UI elements when proxy IPs are invalid/valid */
    ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent));
    ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent));
    connect(ui->proxyIp, SIGNAL(validationDidChange(QValidatedLineEdit *)), this, SLOT(updateProxyValidationState()));
    connect(ui->proxyIpTor, SIGNAL(validationDidChange(QValidatedLineEdit *)), this, SLOT(updateProxyValidationState()));
    connect(ui->proxyPort, SIGNAL(textChanged(const QString&)), this, SLOT(updateProxyValidationState()));
    connect(ui->proxyPortTor, SIGNAL(textChanged(const QString&)), this, SLOT(updateProxyValidationState()));
}
예제 #6
0
OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
    : QDialog(parent)
    , ui(new Ui::OptionsDialog)
    , model(0)
    , mapper(0)
{
    ui->setupUi(this);

    /* Main elements init */
    ui->databaseCache->setMinimum(nMinDbCache);
    ui->databaseCache->setMaximum(nMaxDbCache);
    ui->threadsScriptVerif->setMinimum(-GetNumCores());
    ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);

    QFrame* horizontalLine = new QFrame(this);
    horizontalLine->setFrameStyle(QFrame::HLine);
    horizontalLine->setFixedHeight(1);
    horizontalLine->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    horizontalLine->setStyleSheet(GULDEN_DIALOG_HLINE_STYLE_NOMARGIN);
    ui->verticalLayout->insertWidget(2, horizontalLine);

    setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);

    ui->okButton->setCursor(Qt::PointingHandCursor);
    ui->cancelButton->setCursor(Qt::PointingHandCursor);
    ui->resetButton->setCursor(Qt::PointingHandCursor);

/* Network elements init */
#ifndef USE_UPNP
    ui->mapPortUpnp->setEnabled(false);
#endif

    ui->proxyIp->setEnabled(false);
    ui->proxyPort->setEnabled(false);
    ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));

    ui->proxyIpTor->setEnabled(false);
    ui->proxyPortTor->setEnabled(false);
    ui->proxyPortTor->setValidator(new QIntValidator(1, 65535, this));

    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(toggled(bool)), this, SLOT(updateProxyValidationState()));

    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyIpTor, SLOT(setEnabled(bool)));
    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyPortTor, SLOT(setEnabled(bool)));
    connect(ui->connectSocksTor, SIGNAL(toggled(bool)), this, SLOT(updateProxyValidationState()));

/* Window elements init */
#ifdef Q_OS_MAC
    /* remove Window tab on Mac */
    ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
#endif

    /* remove Wallet tab in case of -disablewallet */
    if (!enableWallet) {
        ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWallet));
    }

    /* Display elements init */
    QDir translations(":translations");

    ui->bitcoinAtStartup->setToolTip(ui->bitcoinAtStartup->toolTip().arg(tr(PACKAGE_NAME)));
    ui->bitcoinAtStartup->setText(ui->bitcoinAtStartup->text().arg(tr(PACKAGE_NAME)));

    ui->lang->setToolTip(ui->lang->toolTip().arg(tr(PACKAGE_NAME)));
    ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
    Q_FOREACH (const QString& langStr, translations.entryList()) {
        QLocale locale(langStr);

        /** check if the locale name consists of 2 parts (language_country) */
        if (langStr.contains("_")) {
#if QT_VERSION >= 0x040800
            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
            /** display language strings as "language - country (locale name)", e.g. "German - Germany (de)" */
            ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" - ") + QLocale::countryToString(locale.country()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
        } else {
#if QT_VERSION >= 0x040800
            /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
            /** display language strings as "language (locale name)", e.g. "German (de)" */
            ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
        }
    }
#if QT_VERSION >= 0x040700
    ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s");
#endif

    ui->unit->setModel(new BitcoinUnits(this));

    /* Widget-to-option mapper */
    mapper = new QDataWidgetMapper(this);
    mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    mapper->setOrientation(Qt::Vertical);

    /* setup/change UI elements when proxy IPs are invalid/valid */
    ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent));
    ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent));
    connect(ui->proxyIp, SIGNAL(validationDidChange(QValidatedLineEdit*)), this, SLOT(updateProxyValidationState()));
    connect(ui->proxyIpTor, SIGNAL(validationDidChange(QValidatedLineEdit*)), this, SLOT(updateProxyValidationState()));
    connect(ui->proxyPort, SIGNAL(textChanged(const QString&)), this, SLOT(updateProxyValidationState()));
    connect(ui->proxyPortTor, SIGNAL(textChanged(const QString&)), this, SLOT(updateProxyValidationState()));
}
예제 #7
0
파일: cgroup.cpp 프로젝트: noxiouz/porto
TError TCpuSubsystem::SetCpuPolicy(TCgroup &cg, const std::string &policy,
                                   double guarantee, double limit) {
    TError error;

    if (HasQuota) {
        int64_t quota = std::ceil(limit * BasePeriod);

        if (quota < 1000)
            quota = 1000;

        if (limit >= GetNumCores())
            quota = -1;

        error = cg.Set("cpu.cfs_quota_us", std::to_string(quota));
        if (error)
            return error;
    }

    if (HasReserve) {
        uint64_t reserve = std::floor(guarantee * BasePeriod);
        uint64_t shares = BaseShares, reserve_shares = BaseShares;

        if (policy == "rt") {
            shares *= 16;
            reserve_shares *= 256;
        } else if (policy == "normal") {
            reserve_shares *= 16;
        } else if (policy == "idle") {
            shares /= 16;
        }

        error = cg.SetUint64("cpu.shares", shares);
        if (error)
            return error;

        error = cg.SetUint64("cpu.cfs_reserve_shares", reserve_shares);
        if (error)
            return error;

        error = cg.SetUint64("cpu.cfs_reserve_us", reserve);
        if (error)
            return error;

    } else if (HasShares) {
        uint64_t shares = std::floor((guarantee + 1) * BaseShares);

        if (policy == "rt" && (!HasSmart || !config().container().enable_smart()))
            shares *= 16;
        else if (policy == "idle")
            shares /= 16;

        error = cg.SetUint64("cpu.shares", shares);
        if (error)
            return error;
    }

    if (HasSmart) {
        error = cg.SetUint64("cpu.smart", (policy == "rt" &&
                    config().container().enable_smart()) ? 1 : 0);
        if (error)
            return error;
    }

    return TError::Success();
}
예제 #8
0
acacheSGA::acacheSGA(int type) {
	void *ptr;
	int i = 0;
	int numTSQGKVdata;
	//_adapt_::adaptThreadedSharedPort	*P1, *P2 ;

	DBUG(ALOG_DALL,
			"(%p)acacheSGA:(%p)Construct::Type:%d", pthread_self(), this, type);
	this->type = type;

	this->hashsize = ACACHED_HASH_SIZE;
	this->hashsize_power =
			(int) (floor(log((float) this->hashsize) / log(2.0)));
	this->hashmask = this->hashsize - 1;

	this->hash_lock_ratio = ACACHED_HASH_LOCK_RATIO;
	this->hash_lock_ratio_power = (int) (floor(log((float) this->hash_lock_ratio) / log(2.0)));
	this->hash_lock_count = (unsigned long) (1 << (this->hashsize_power - this->hash_lock_ratio_power));
	this->hash_lock_mask = this->hash_lock_count - 1;

	this->numCores = GetNumCores();

	this->aSQGSharedQ = new _adapt_::adaptSharedQ(Q_TYPE_GLOBAL_SQ);
	this->aSQGFreebusySQ = new _adapt_::adaptSharedQ(Q_TYPE_GLOBAL_FBQ);
	this->aSQGThreadedSQ = new _adapt_::adaptSharedQ(Q_TYPE_GLOBAL_TSQ);

	this->aSQGthreads = new _adapt_::adaptSharedQ(Q_TYPE_GLOBAL_THREADS);
	this->aSQGSharedQ->aSQput(this->aSQGthreads);

	this->aSQGprocessCommandBusy = new _adapt_::adaptSharedQ(Q_TYPE_PROCESS_CMD_BUSY);
	this->aSQGSharedQ->aSQput(this->aSQGprocessCommandBusy);

	this->aFBSQGaMsg = new _adapt_::adaptFBSharedQ(FBSQ_TYPE_GLOBAL_MSGS,Q_TYPE_GLOBAL_MSGS);
	this->aSQGFreebusySQ->aSQput(this->aFBSQGaMsg);

	this->aFBSQGaConn = new _adapt_::adaptFBSharedQ(FBSQ_TYPE_GLOBAL_CONN,Q_TYPE_GLOBAL_CONN);
	this->aSQGFreebusySQ->aSQput(this->aFBSQGaConn);

	this->aFBSQGaLock = new _adapt_::adaptFBSharedQ(FBSQ_TYPE_GLOBAL_LOCK,Q_TYPE_GLOBAL_LOCK);
	this->aSQGFreebusySQ->aSQput(this->aFBSQGaLock);

	// allocate hash KVdata bucket Queues
	this->ahashtableptr = new ahashtable(this->hashsize,
			this->hash_lock_ratio_power);

	for (i = 0; i < INIT_COUNT_GLOBAL_MSG; i++) {
		ptr = new aMsg();
		this->aFBSQGaMsg->aFBSQPutFree(ptr);
	}
	INFO(ALOG_TMSG,
			"INIT:MSG:allocating:%d FreeQ(%p)size(%d)BusyQ(%p)size(%d)", INIT_COUNT_GLOBAL_MSG, this->aFBSQGaMsg->FreeQ->Q, this->aFBSQGaMsg->FreeQ->Q->size(), this->aFBSQGaMsg->BusyQ->Q, this->aFBSQGaMsg->BusyQ->Q->size());

	for (i = 0; i < INIT_COUNT_GLOBAL_CONN; i++) {
		ptr = new aConn(CONN_TYPE_NONE, -1);
		this->aFBSQGaConn->aFBSQPutFree(ptr);
	}
	INFO(ALOG_TCONN,
			"INIT:ACONN:allocating:%d FreeQ(%p)size(%d)BusyQ(%p)size(%d)", INIT_COUNT_GLOBAL_CONN, this->aFBSQGaConn->FreeQ->Q, this->aFBSQGaConn->FreeQ->Q->size(), this->aFBSQGaConn->BusyQ->Q, this->aFBSQGaConn->BusyQ->Q->size());

	/*
	 this->aTSQGprocessCommand = new _adapt_::adaptThreadedSharedQ(
	 Q_TYPE_PROCESS_CMD, THREAD_TYPE_PROCESS_CMD,INIT_COUNT_THREAD_PROCESS_CMD,
	 thrProcessCommand,this->aSQGthreads
	 );
	 this->aSQGThreadedSQ->aSQput(this->aTSQGprocessCommand);


	 this->aTSQGgetHash = new _adapt_::adaptThreadedSharedQ(
	 Q_TYPE_GET_HASH, THREAD_TYPE_GET_HASH,INIT_COUNT_THREAD_GET_HASH,
	 thrIN,this->aSQGthreads
	 );
	 this->aSQGThreadedSQ->aSQput(this->aTSQGgetHash);



	 this->aTSQGgetMem = new _adapt_::adaptThreadedSharedQ(
	 Q_TYPE_GET_MEM, THREAD_TYPE_GET_MEM,INIT_COUNT_THREAD_GET_MEM,
	 thrIN,this->aSQGthreads
	 );
	 this->aSQGThreadedSQ->aSQput(this->aTSQGgetMem);
	 */

	numTSQGKVdata = this->numCores;
//	numTSQGKVdata=1;

	this->aTSQGKVdata = (_adapt_::adaptThreadedSharedQ **) (malloc(
			sizeof(KVdata *) * numTSQGKVdata));

	for (i = 0; i < (INIT_COUNT_THREAD_KVDATA / numTSQGKVdata + 1); i++) {
		this->aTSQGKVdata[i] = new _adapt_::adaptThreadedSharedQ(
				Q_TYPE_KVDATA, THREAD_TYPE_KVDATA,INIT_COUNT_THREAD_KVDATA / numTSQGKVdata, thrKVdata,
				this->aSQGthreads);
		this->aSQGThreadedSQ->aSQput((this->aTSQGKVdata[i]));
		fprintf(stderr, "\nkvdata--> index %d ", i);
	}

	/**
	 this->aTSQGClient = new _adapt_::adaptThreadedSharedQ(
	 Q_TYPE_CLIENT, THREAD_TYPE_CLIENT,INIT_COUNT_THREAD_CLIENT,
	 thrClient,this->aSQGthreads
	 );
	 this->aSQGThreadedSQ->aSQput(this->aTSQGClient);
	 **/

	for (i = 0; i < ACACHED_THREAD_COMM_MAX; i++)
		this->aTcomm[i] = new _adapt_::adaptThreadComm(THREAD_TYPE_COMM,
				thrComm, this->aSQGthreads);

	ALERT(ALOG_INFO, "\nInitialization Done %s !!!!!\n", "hello");
	//this->aSQGthreads->aSQprintall("ALL THREADS", PrintGthreads);
	this->aSQGFreebusySQ->aSQprintall("Check freebusy", PrintGFreebusySQ);
}
예제 #9
0
OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
    QDialog(parent),
    ui(new Ui::OptionsDialog),
    model(nullptr),
    mapper(nullptr)
{
    ui->setupUi(this);

    /* Main elements init */
    ui->databaseCache->setMinimum(nMinDbCache);
    ui->databaseCache->setMaximum(nMaxDbCache);
    ui->threadsScriptVerif->setMinimum(-GetNumCores());
    ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
    ui->pruneWarning->setVisible(false);
    ui->pruneWarning->setStyleSheet("QLabel { color: red; }");

    ui->pruneSize->setEnabled(false);
    connect(ui->prune, &QPushButton::toggled, ui->pruneSize, &QWidget::setEnabled);

    /* Network elements init */
#ifndef USE_UPNP
    ui->mapPortUpnp->setEnabled(false);
#endif

    ui->proxyIp->setEnabled(false);
    ui->proxyPort->setEnabled(false);
    ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));

    ui->proxyIpTor->setEnabled(false);
    ui->proxyPortTor->setEnabled(false);
    ui->proxyPortTor->setValidator(new QIntValidator(1, 65535, this));

    connect(ui->connectSocks, &QPushButton::toggled, ui->proxyIp, &QWidget::setEnabled);
    connect(ui->connectSocks, &QPushButton::toggled, ui->proxyPort, &QWidget::setEnabled);
    connect(ui->connectSocks, &QPushButton::toggled, this, &OptionsDialog::updateProxyValidationState);

    connect(ui->connectSocksTor, &QPushButton::toggled, ui->proxyIpTor, &QWidget::setEnabled);
    connect(ui->connectSocksTor, &QPushButton::toggled, ui->proxyPortTor, &QWidget::setEnabled);
    connect(ui->connectSocksTor, &QPushButton::toggled, this, &OptionsDialog::updateProxyValidationState);

    /* Window elements init */
#ifdef Q_OS_MAC
    /* remove Window tab on Mac */
    ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
#if  defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED > 101100
    /* hide launch at startup option if compiled against macOS > 10.11 (removed API) */
    ui->bitcoinAtStartup->setVisible(false);
    ui->verticalLayout_Main->removeWidget(ui->bitcoinAtStartup);
    ui->verticalLayout_Main->removeItem(ui->horizontalSpacer_0_Main);
#endif
#endif

    /* remove Wallet tab in case of -disablewallet */
    if (!enableWallet) {
        ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWallet));
    }

    /* Display elements init */
    QDir translations(":translations");

    ui->bitcoinAtStartup->setToolTip(ui->bitcoinAtStartup->toolTip().arg(tr(PACKAGE_NAME)));
    ui->bitcoinAtStartup->setText(ui->bitcoinAtStartup->text().arg(tr(PACKAGE_NAME)));

    ui->openBitcoinConfButton->setToolTip(ui->openBitcoinConfButton->toolTip().arg(tr(PACKAGE_NAME)));

    ui->lang->setToolTip(ui->lang->toolTip().arg(tr(PACKAGE_NAME)));
    ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
    for (const QString &langStr : translations.entryList())
    {
        QLocale locale(langStr);

        /** check if the locale name consists of 2 parts (language_country) */
        if(langStr.contains("_"))
        {
            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
        }
        else
        {
            /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
        }
    }
    ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s");

    ui->unit->setModel(new BitcoinUnits(this));

    /* Widget-to-option mapper */
    mapper = new QDataWidgetMapper(this);
    mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    mapper->setOrientation(Qt::Vertical);

    GUIUtil::ItemDelegate* delegate = new GUIUtil::ItemDelegate(mapper);
    connect(delegate, &GUIUtil::ItemDelegate::keyEscapePressed, this, &OptionsDialog::reject);
    mapper->setItemDelegate(delegate);

    /* setup/change UI elements when proxy IPs are invalid/valid */
    ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent));
    ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent));
    connect(ui->proxyIp, &QValidatedLineEdit::validationDidChange, this, &OptionsDialog::updateProxyValidationState);
    connect(ui->proxyIpTor, &QValidatedLineEdit::validationDidChange, this, &OptionsDialog::updateProxyValidationState);
    connect(ui->proxyPort, &QLineEdit::textChanged, this, &OptionsDialog::updateProxyValidationState);
    connect(ui->proxyPortTor, &QLineEdit::textChanged, this, &OptionsDialog::updateProxyValidationState);

    if (!QSystemTrayIcon::isSystemTrayAvailable()) {
        ui->hideTrayIcon->setChecked(true);
        ui->hideTrayIcon->setEnabled(false);
        ui->minimizeToTray->setChecked(false);
        ui->minimizeToTray->setEnabled(false);
    }
}