예제 #1
0
 void operator()(R&& rvar, T&& tvar) const
 {
   // Derive the symmetric complement of r and quantify over it. I
   // wouldn't need to do this if I had a symmetric_complement function.
   using U = Result_of<T()>;
   auto r = rvar();
   auto sc = [r](const U& a, const U& b) { return !r(a, b) && !r(b, a); }; 
   auto svar = single(sc);
   
   quick_check(ord, rvar, tvar);
   quick_check(eq, svar, tvar);
 }
예제 #2
0
 void 
 check_strict_total_ordering(R r)
 {
   auto rvar = single(r);
   auto tvar = quantify_over<Domain<R>>();
   quick_check(strict_total_ordering {}, rvar, tvar);
 }
예제 #3
0
 void 
 check_equivalence(R r)
 {
   auto rvar = single(r);
   auto tvar = quantify_over<Domain<R>>();
   quick_check(equivalence {}, rvar, tvar);
 }
예제 #4
0
 void 
 check_trichotomous(R r)
 {
   auto rvar = single(r);
   auto tvar = quantify_over<Domain<R>>();
   quick_check(trichotomous {}, rvar, tvar);
 }
예제 #5
0
 void 
 check_transitive(R r)
 {
   auto rvar = single(r);
   auto tvar = quantify_over<Domain<R>>();
   quick_check(transitive {}, rvar, tvar, tvar, tvar);
 }
예제 #6
0
 void 
 check_antisymmetric(R r)
 {
   auto rvar = single(r);
   auto tvar = quantify_over<Domain<R>>();
   quick_check(antisymmetric {}, rvar, tvar, tvar);
 }
예제 #7
0
 void 
 check_irreflexive(R r)
 {
   auto rvar = single(r);
   auto tvar = quantify_over<Domain<R>>();
   quick_check(irreflexive {}, rvar, tvar);
 }
예제 #8
0
파일: ownsql.cpp 프로젝트: owncloud/client
SqlDatabase::CheckDbResult SqlDatabase::checkDb()
{
    // quick_check can fail with a disk IO error when diskspace is low
    SqlQuery quick_check(*this);

    if (quick_check.prepare("PRAGMA quick_check;", /*allow_failure=*/true) != SQLITE_OK) {
        qCWarning(lcSql) << "Error preparing quick_check on database";
        _errId = quick_check.errorId();
        _error = quick_check.error();
        return CheckDbResult::CantPrepare;
    }
    if (!quick_check.exec()) {
        qCWarning(lcSql) << "Error running quick_check on database";
        _errId = quick_check.errorId();
        _error = quick_check.error();
        return CheckDbResult::CantExec;
    }

    quick_check.next();
    QString result = quick_check.stringValue(0);
    if (result != "ok") {
        qCWarning(lcSql) << "quick_check returned failure:" << result;
        return CheckDbResult::NotOk;
    }

    return CheckDbResult::Ok;
}
예제 #9
0
 void 
 check_reflexive(R r)
 {
   using D = Domain<R>;
   auto rvar = single(r);
   auto tvar = quantify_over<D>();
   quick_check(reflexive {}, rvar, tvar);
 }
예제 #10
0
bool SqlDatabase::checkDb()
{
    SqlQuery quick_check("PRAGMA quick_check;", *this);
    if( !quick_check.exec() ) {
        qDebug() << "Error running quick_check on database";
        return false;
    }

    quick_check.next();
    QString result = quick_check.stringValue(0);
    if( result != "ok" ) {
        qDebug() << "quick_check returned failure:" << result;
        return false;
    }

    return true;
}
예제 #11
0
파일: spaces.c 프로젝트: Thog/ft_ls
t_space			*get_spaces(t_args *args, t_file *files)
{
	t_file	*tmp;
	t_space	*space;

	if (!(space = init_spaces()))
		return (NULL);
	tmp = files;
	while (tmp)
	{
		if (!(args->a == 0 && tmp->name[0] == '.'))
		{
			quick_check(space, tmp);
			get_spaces_sys(space, tmp);
		}
		tmp = tmp->next;
	}
	return (space);
}
예제 #12
0
// Make a pass through the wu/results array, sending work.
// The choice of jobs is limited by flags in g_wreq, as follows:
// infeasible_only:
//      send only results that were previously infeasible for some host
// reliable_only:
//      send only jobs with "need_reliable" set (e.g. retries)
//      and send them only w/ app versions that are "reliable" for this host
// user_apps_only:
//      Send only jobs for apps selected by user
// beta_only:
//      Send only jobs for beta-test apps
// locality_sched_lite:
//      For apps that use locality sched Lite,
//      send only jobs for which the host already has at least 1 file
//
// Return true if no more work is needed.
//
static bool scan_work_array() {
    int i, j, rnd_off, last_retval=0;;
    APP* app;
    BEST_APP_VERSION* bavp;
    bool no_more_needed = false;
    SCHED_DB_RESULT result;

    // To minimize the amount of time we lock the array,
    // we initially scan without holding the lock.
    // If we find a job that passes quick_check(),
    // we acquire the lock and then check the job again.
    //
    bool sema_locked = false;

    rnd_off = rand() % ssp->max_wu_results;
    for (j=0; j<ssp->max_wu_results; j++) {
        i = (j+rnd_off) % ssp->max_wu_results;

        WU_RESULT& wu_result = ssp->wu_results[i];

        if (config.debug_send_job) {
            log_messages.printf(MSG_NORMAL,
                "[send_job] scanning slot %d\n", i
            );
        }

recheck:
        if (wu_result.state != WR_STATE_PRESENT && wu_result.state != g_pid) {
            continue;
        }

        // make a copy of the WORKUNIT part,
        // which we can modify without affecting the cache
        //
        WORKUNIT wu = wu_result.workunit;

        app = ssp->lookup_app(wu_result.workunit.appid);
        if (app == NULL) {
            log_messages.printf(MSG_CRITICAL,
                "[WU#%lu] no app\n",
                wu_result.workunit.id
            );
            continue; // this should never happen
        }

        if (app->non_cpu_intensive) continue;

        // do fast (non-DB) checks.
        // This may modify wu.rsc_fpops_est
        //
        if (!quick_check(wu_result, wu, bavp, app, last_retval)) {
            if (config.debug_send_job) {
                log_messages.printf(MSG_NORMAL,
                    "[send_job] slot %d failed quick check\n", i
                );
            }
            continue;
        }

        if (!sema_locked) {
            lock_sema();
            sema_locked = true;
            goto recheck;
        }

        // mark wu_result as checked out and release semaphore.
        // from here on in this loop, don't continue on failure;
        // instead, goto dont_send (so that we reacquire semaphore)
        //
        // Note: without the semaphore we don't have mutual exclusion;
        // ideally we should use a transaction from now until when
        // we commit to sending the results.

        wu_result.state = g_pid;
        unlock_sema();
        sema_locked = false;

        switch (slow_check(wu_result, app, bavp)) {
        case 1:
            // if we couldn't send the result to this host,
            // set its state back to PRESENT
            //
            wu_result.state = WR_STATE_PRESENT;
            break;
        case 2:
            // can't send this job to any host
            //
            wu_result.state = WR_STATE_EMPTY;
            break;
        default:
            // slow_check() refreshes fields of wu_result.workunit;
            // update our copy too
            //
            wu.hr_class = wu_result.workunit.hr_class;
            wu.app_version_id = wu_result.workunit.app_version_id;

            // mark slot as empty AFTER we've copied out of it
            // (since otherwise feeder might overwrite it)
            //
            wu_result.state = WR_STATE_EMPTY;

            // reread result from DB, make sure it's still unsent
            // TODO: from here to end of add_result_to_reply()
            // (which updates the DB record) should be a transaction
            //
            result.id = wu_result.resultid;
            if (result_still_sendable(result, wu)) {
                add_result_to_reply(result, wu, bavp, false);

                // add_result_to_reply() fails only in pathological cases -
                // e.g. we couldn't update the DB record or modify XML fields.
                // If this happens, don't replace the record in the array
                // (we can't anyway, since we marked the entry as "empty").
                // The feeder will eventually pick it up again,
                // and hopefully the problem won't happen twice.
            }
            break;
        }
        if (!work_needed(false)) {
            no_more_needed = true;
            break;
        }
    }
    if (sema_locked) {
        unlock_sema();
    }
    return no_more_needed;
}
// Make a pass through the wu/results array, sending work.
// The choice of jobs is limited by flags in g_wreq, as follows:
// infeasible_only:
//      send only results that were previously infeasible for some host
// reliable_only: 
//      send only retries
// user_apps_only:
//      Send only jobs for apps selected by user
// beta_only:
//      Send only jobs for beta-test apps
//
// Return true if no more work is needed.
//
static bool scan_work_array() {
    int i, j, retval, rnd_off, last_retval=0;;
    APP* app;
    BEST_APP_VERSION* bavp;
    bool no_more_needed = false;
    DB_RESULT result;

    lock_sema();
    
    rnd_off = rand() % ssp->max_wu_results;
    for (j=0; j<ssp->max_wu_results; j++) {
        i = (j+rnd_off) % ssp->max_wu_results;

        WU_RESULT& wu_result = ssp->wu_results[i];
        WORKUNIT wu = wu_result.workunit;

        // do fast (non-DB) checks
        //
        if (!quick_check(wu_result, wu, bavp, app, last_retval)) {
            continue;
        }

        // mark wu_result as checked out and release semaphore.
        // from here on in this loop, don't continue on failure;
        // instead, goto dont_send (so that we reacquire semaphore)
        //
        // Note: without the semaphore we don't have mutual exclusion;
        // ideally we should use a transaction from now until when
        // we commit to sending the results.

        wu_result.state = g_pid;
        unlock_sema();

        if (!slow_check(wu_result, wu, app)) {
            // if we couldn't send the result to this host,
            // set its state back to PRESENT
            //
            wu_result.state = WR_STATE_PRESENT;
        } else {
            result.id = wu_result.resultid;

            // mark slot as empty AFTER we've copied out of it
            // (since otherwise feeder might overwrite it)
            //
            wu_result.state = WR_STATE_EMPTY;

            // reread result from DB, make sure it's still unsent
            // TODO: from here to end of add_result_to_reply()
            // (which updates the DB record) should be a transaction
            //
            if (result_still_sendable(result, wu)) {
                retval = add_result_to_reply(result, wu, bavp, false);

                // add_result_to_reply() fails only in pathological cases -
                // e.g. we couldn't update the DB record or modify XML fields.
                // If this happens, don't replace the record in the array
                // (we can't anyway, since we marked the entry as "empty").
                // The feeder will eventually pick it up again,
                // and hopefully the problem won't happen twice.
            }
        }
        lock_sema();
        if (!work_needed(false)) {
            no_more_needed = true;
            break;
        }
    }
    unlock_sema();
    return no_more_needed;
}
예제 #14
0
 void operator()(R&& rvar, T&& tvar) const
 {
   quick_check(trans, rvar, tvar, tvar, tvar);
   quick_check(tri, rvar, tvar, tvar);
 }
예제 #15
0
 void operator()(R&& rvar, T&& tvar) const
 {
   quick_check(irrefl, rvar, tvar);
   quick_check(asym, rvar, tvar, tvar);
   quick_check(trans, rvar, tvar, tvar, tvar);
 }