text:
/**
 *    Copyright (C) 2013 10gen Inc.
 *
 *    This program is free software: you can redistribute it and/or  modify
 *    it under the terms of the GNU Affero General Public License, version 3,
 *    as published by the Free Software Foundation.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU Affero General Public License for more details.
 *
 *    You should have received a copy of the GNU Affero General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *    As a special exception, the copyright holders give permission to link the
 *    code of portions of this program with the OpenSSL library under certain
 *    conditions as described in each individual source file and distribute
 *    linked combinations including the program with the OpenSSL library. You
 *    must comply with the GNU Affero General Public License in all respects for
 *    all of the code used other than as permitted herein. If you modify file(s)
 *    with this exception, you may extend this exception to your version of the
 *    file(s), but you are not obligated to do so. If you do not wish to do so,
 *    delete this exception statement from your version. If you delete this
 *    exception statement from all source files in the program, then also delete
 *    it in the license file.
 */

#include "mongo/db/range_deleter.h"

#include <boost/date_time/posix_time/posix_time_duration.hpp>
#include <memory>

#include "mongo/s/range_arithmetic.h"
#include "mongo/db/range_deleter_stats.h"
#include "mongo/util/concurrency/synchronization.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/time_support.h"

using std::auto_ptr;
using std::set;
using std::pair;
using std::string;

using mongoutils::str::stream;

namespace {
    const long int NotEmptyTimeoutMillis = 200;
    const long long int MaxCurorCheckIntervalMillis = 500;

    /**
     * Removes an element from the container that holds a pointer type, and deletes the
     * pointer as well. Returns true if the element was found.
     */
    template <typename ContainerType, typename ContainerElementType>
    bool deletePtrElement(ContainerType* container, ContainerElementType elem) {
        typename ContainerType::iterator iter = container->find(elem);

        if (iter == container->end()) {
            return false;
        }

        delete *iter;
        container->erase(iter);
        return true;
    }
}

namespace mongo {

    namespace duration = boost::posix_time;

    struct RangeDeleter::RangeDeleteEntry {
        RangeDeleteEntry():
                secondaryThrottle(true),
                notifyDone(NULL) {
        }

        std::string ns;

        // Inclusive lower range.
        BSONObj min;

        // Exclusive upper range.
        BSONObj max;

        // The key pattern of the index the range refers to.
        // This is relevant especially with special indexes types
        // like hash indexes.
        BSONObj shardKeyPattern;

        bool secondaryThrottle;

        // Sets of cursors to wait to close until this can be ready
        // for deletion.
        std::set<CursorId> cursorsToWait;

        // Not owned here.
        // Important invariant: Can only be set and used by one thread.
        Notification* notifyDone;

        // For debugging only
        BSONObj toBSON() const {
            return BSON("ns" << ns
                    << "min" << min
                    << "max" << max
                    << "notifyDoneAddr" << reinterpret_cast<long long>(notifyDone));
        }
    };

    struct RangeDeleter::NSMinMax {
        NSMinMax(std::string ns, const BSONObj min, const BSONObj max):
            ns(ns), min(min), max(max) {
        }

        std::string ns;

        // Inclusive lower range.
        BSONObj min;

        // Exclusive upper range.
        BSONObj max;
    };

    bool RangeDeleter::NSMinMaxCmp::operator()(
            const NSMinMax* lhs, const NSMinMax* rhs) const {
        const int nsComp = lhs->ns.compare(rhs->ns);

        if (nsComp < 0) {
            return true;
        }

        if (nsComp > 0) {
            return false;
        }

        return compareRanges(lhs->min, lhs->max, rhs->min, rhs->max) < 0;
    }

    RangeDeleter::RangeDeleter(RangeDeleterEnv* env):
        _env(env), // ownership xfer
        _stopMutex("stopRangeDeleter"),
        _stopRequested(false),
        _queueMutex("RangeDeleter"),
        _stats(new RangeDeleterStats(&_queueMutex)) {
    }

    RangeDeleter::~RangeDeleter() {
        for(TaskList::iterator it = _notReadyQueue.begin();
            it != _notReadyQueue.end();
            ++it) {
            delete (*it);
        }

        for(TaskList::iterator it = _taskQueue.begin();
            it != _taskQueue.end();
            ++it) {
            delete (*it);
        }

        for(NSMinMaxSet::iterator it = _deleteSet.begin();
            it != _deleteSet.end();
            ++it) {
            delete (*it);
        }

        for(NSMinMaxSet::iterator it = _blackList.begin();
            it != _blackList.end();
            ++it) {
            delete (*it);
        }
    }

    void RangeDeleter::startWorkers() {
        if (!_worker) {
            _worker.reset(new boost::thread(boost::bind(&RangeDeleter::doWork, this)));
        }
    }

    void RangeDeleter::stopWorkers() {
        {
            scoped_lock sl(_stopMutex);
            _stopRequested = true;
        }

        if (_worker) {
            _worker->join();
        }

        scoped_lock sl(_queueMutex);
        while (_stats->hasInProgress_inlock()) {
            _nothingInProgressCV.wait(sl.boost());
        }
    }

    bool RangeDeleter::queueDelete(const std::string& ns,
                                   const BSONObj& min,
                                   const BSONObj& max,
                                   const BSONObj& shardKeyPattern,
                                   bool secondaryThrottle,
                                   Notification* notifyDone,
                                   std::string* errMsg) {
        string dummy;
        if (errMsg == NULL) errMsg = &dummy;

        auto_ptr<RangeDeleteEntry> toDelete(new RangeDeleteEntry);
        toDelete->ns = ns;
        toDelete->min = min.getOwned();
        toDelete->max = max.getOwned();
        toDelete->shardKeyPattern = shardKeyPattern.getOwned();
        toDelete->secondaryThrottle = secondaryThrottle;
        toDelete->notifyDone = notifyDone;

        {
            scoped_lock sl(_queueMutex);
            if (_stopRequested) {
                *errMsg = "deleter is already stopped.";
                return false;
            }

            if (!canEnqueue_inlock(ns, min, max, errMsg)) {
                return false;
            }

            _deleteSet.insert(new NSMinMax(ns, min, max));
            _stats->incTotalDeletes_inlock();
            _stats->incPendingDeletes_inlock();
        }

        _env->getCursorIds(ns, &toDelete->cursorsToWait);

        {
            scoped_lock sl(_queueMutex);

            if (toDelete->cursorsToWait.empty()) {
                _taskQueue.push_back(toDelete.release());
                _taskQueueNotEmptyCV.notify_one();
            }
            else {
                log() << "rangeDeleter waiting for " << toDelete->cursorsToWait.size()
                      << " cursors in " << ns << " to finish" << endl;

                _notReadyQueue.push_back(toDelete.release());
            }
        }

        return true;
    }

    bool RangeDeleter::deleteNow(const std::string& ns,
                                 const BSONObj& min,
                                 const BSONObj& max,
                                 const BSONObj& shardKeyPattern,
                                 bool secondaryThrottle,
                                 string* errMsg) {
        if (stopRequested()) {
            *errMsg = "deleter is already stopped.";
            return false;
        }

        string dummy;
        if (errMsg == NULL) errMsg = &dummy;

        NSMinMax deleteRange(ns, min, max);
        {
            scoped_lock sl(_queueMutex);
            if (!canEnqueue_inlock(ns, min, max, errMsg)) {
                return false;
            }

            _deleteSet.insert(&deleteRange);
            _stats->incTotalDeletes_inlock();

            // Note: count for pending deletes is an integral part of the shutdown story.
            // Therefore, to simplify things, there is no "pending" state for deletes in
            // deleteNow, the state transition is simply inProgress -> done.
            _stats->incInProgressDeletes_inlock();
        }

        set<CursorId> cursorsToWait;
        _env->getCursorIds(ns, &cursorsToWait);

        long long checkIntervalMillis = 5;

        if (!cursorsToWait.empty()) {
            log() << "rangeDeleter waiting for " << cursorsToWait.size()
                  << " cursors in " << ns << " to finish" << endl;
        }

        while (!cursorsToWait.empty()) {
            set<CursorId> cursorsNow;
            _env->getCursorIds(ns, &cursorsNow);

            set<CursorId> cursorsLeft;
            std::set_intersection(cursorsToWait.begin(),
                                  cursorsToWait.end(),
                                  cursorsNow.begin(),
                                  cursorsNow.end(),
                                  std::inserter(cursorsLeft, cursorsLeft.end()));

            cursorsToWait.swap(cursorsLeft);

            if (stopRequested()) {
                *errMsg = "deleter was stopped.";

                scoped_lock sl(_queueMutex);
                _deleteSet.erase(&deleteRange);

                _stats->decInProgressDeletes_inlock();
                _stats->decTotalDeletes_inlock();

                if (!_stats->hasInProgress_inlock()) {
                    _nothingInProgressCV.notify_one();
                }

                return false;
            }

            if (checkIntervalMillis < MaxCurorCheckIntervalMillis) {
                checkIntervalMillis *= 2;
            }

            sleepmillis(checkIntervalMillis);
        }

        bool result = _env->deleteRange(ns, min, max, shardKeyPattern,
                                        secondaryThrottle, errMsg);

        {
            scoped_lock sl(_queueMutex);
            _deleteSet.erase(&deleteRange);

            _stats->decInProgressDeletes_inlock();
            _stats->decTotalDeletes_inlock();

            if (!_stats->hasInProgress_inlock()) {
                _nothingInProgressCV.notify_one();
            }
        }

        return result;
    }

    bool RangeDeleter::addToBlackList(const StringData& ns,
                                      const BSONObj& min,
                                      const BSONObj& max,
                                      std::string* errMsg) {
        string dummy;
        if (errMsg == NULL) errMsg = &dummy;

        scoped_lock sl(_queueMutex);

        if (isBlacklisted_inlock(ns, min, max, errMsg)) {
            return false;
        }

        for (NSMinMaxSet::const_iterator iter = _deleteSet.begin();
                iter != _deleteSet.end(); ++iter) {
            const NSMinMax* const entry = *iter;
            if (entry->ns == ns && rangeOverlaps(entry->min, entry->max, min, max)) {
                *errMsg = stream() << "Cannot black list ns: " << ns
                        << ", min: " << min
                        << ", max: " << max
                        << " since it is already queued for deletion.";
                return false;
            }
        }

        _blackList.insert(new NSMinMax(ns.toString(), min, max));
        return true;
    }

    bool RangeDeleter::removeFromBlackList(const StringData& ns,
                                           const BSONObj& min,
                                           const BSONObj& max) {
        scoped_lock sl(_queueMutex);
        NSMinMax entry(ns.toString(), min, max);
        return deletePtrElement(&_blackList, &entry);
    }

    const RangeDeleterStats* RangeDeleter::getStats() const {
        return _stats.get();
    }

    BSONObj RangeDeleter::toBSON() const {
        scoped_lock sl(_queueMutex);

        BSONObjBuilder builder;

        BSONArrayBuilder notReadyBuilder(builder.subarrayStart("notReady"));
        for (TaskList::const_iterator iter = _notReadyQueue.begin();
                iter != _notReadyQueue.end(); ++iter) {
            notReadyBuilder.append((*iter)->toBSON());
        }
        notReadyBuilder.doneFast();

        BSONArrayBuilder readyBuilder(builder.subarrayStart("ready"));
        for (TaskList::const_iterator iter = _taskQueue.begin();
                iter != _taskQueue.end(); ++iter) {
            readyBuilder.append((*iter)->toBSON());
        }
        readyBuilder.doneFast();

        return builder.obj();
    }

    void RangeDeleter::doWork() {
        _env->initThread();

        while (!inShutdown() && !stopRequested()) {
            string errMsg;

            RangeDeleteEntry* nextTask = NULL;

            {
                scoped_lock sl(_queueMutex);
                while (_taskQueue.empty()) {
                    _taskQueueNotEmptyCV.timed_wait(
                        sl.boost(), duration::milliseconds(NotEmptyTimeoutMillis));

                    if (stopRequested()) {
                        log() << "stopping range deleter worker" << endl;
                        return;
                    }

                    if (_taskQueue.empty()) {
                        // Try to check if some deletes are ready and move them to the
                        // ready queue.

                        TaskList::iterator iter = _notReadyQueue.begin();
                        while (iter != _notReadyQueue.end()) {
                            RangeDeleteEntry* entry = *iter;

                            set<CursorId> cursorsNow;
                            _env->getCursorIds(entry->ns, &cursorsNow);

                            set<CursorId> cursorsLeft;
                            std::set_intersection(entry->cursorsToWait.begin(),
                                                  entry->cursorsToWait.end(),
                                                  cursorsNow.begin(),
                                                  cursorsNow.end(),
                                                  std::inserter(cursorsLeft,
                                                                cursorsLeft.end()));

                            entry->cursorsToWait.swap(cursorsLeft);

                            if (entry->cursorsToWait.empty()) {
                                _taskQueue.push_back(*iter);
                                _taskQueueNotEmptyCV.notify_one();
                                iter = _notReadyQueue.erase(iter);
                            }
                            else {
                                ++iter;
                            }
                        }
                    }
                }

                if (stopRequested()) {
                    log() << "stopping range deleter worker" << endl;
                    return;
                }

                nextTask = _taskQueue.front();
                _taskQueue.pop_front();

                _stats->decPendingDeletes_inlock();
                _stats->incInProgressDeletes_inlock();
            }

            if (!_env->deleteRange(nextTask->ns,
                                   nextTask->min,
                                   nextTask->max,
                                   nextTask->shardKeyPattern,
                                   nextTask->secondaryThrottle,
                                   &errMsg)) {
                warning() << "Error encountered while trying to delete range: "
                          << errMsg << endl;
            }

            {
                scoped_lock sl(_queueMutex);

                NSMinMax setEntry(nextTask->ns, nextTask->min, nextTask->max);
                deletePtrElement(&_deleteSet, &setEntry);
                _stats->decInProgressDeletes_inlock();
                _stats->decTotalDeletes_inlock();

                if (nextTask->notifyDone) {
                    nextTask->notifyDone->notifyOne();
                }

                delete nextTask;
                nextTask = NULL;
            }
        }
    }

    bool RangeDeleter::isBlacklisted_inlock(const StringData& ns,
                                            const BSONObj& min,
                                            const BSONObj& max,
                                            std::string* errMsg) const {
        for (NSMinMaxSet::const_iterator iter = _blackList.begin();
                iter != _blackList.end(); ++iter) {
            const NSMinMax* const entry = *iter;
            if (ns != entry->ns) continue;

            if (rangeOverlaps(min, max, entry->min, entry->max)) {
                *errMsg = stream() << "ns: " << ns
                        << ", min: " << min
                        << ", max: " << max
                        << " intersects with black list"
                        << " min: " << entry->min
                        << ", max: " << entry->max;
                return true;
            }
        }

        return false;
    }

    bool RangeDeleter::canEnqueue_inlock(const StringData& ns,
                                         const BSONObj& min,
                                         const BSONObj& max,
                                         string* errMsg) const {
        if (isBlacklisted_inlock(ns, min, max, errMsg)) {
            return false;
        }

        NSMinMax toDelete(ns.toString(), min, max);
        if (_deleteSet.count(&toDelete) > 0) {
            *errMsg = stream() << "ns: " << ns
                    << ", min: " << min
                    << ", max: " << max
                    << " is already being processed for deletion.";
            return false;
        }

        return true;
    }

    bool RangeDeleter::stopRequested() const {
        scoped_lock sl(_stopMutex);
        return _stopRequested;
    }

}


text: #include <boost/metaparse/v1/next_char.hpp>

ext: hpp

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
/* Copyright 2010 (C) Stanford University.
 *
 * This file is part of NOX.
 *
 * NOX is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * NOX is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with NOX.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef lavi_hosts_HH
#define lavi_hosts_HH

#include "component.hh"
#include "config.h"
#include "lavi_nodes.hh"
#include "hoststate/hosttracker.hh"

#ifdef LOG4CXX_ENABLED
#include <boost/format.hpp>
#include "log4cxx/logger.h"
#else
#include "vlog.hh"
#endif

namespace vigil
{
  using namespace std;
  using namespace vigil::container;

  /** \brief lavi_hosts: Expose hosts to GUI
   * \ingroup noxcomponents
   *
   * A request should be of the following JSON form
   *

   * {
   *   "type" : "lavi"
   *   "command" : <string | "request", "subscribe", "unsubscribe">
   *   "node_type" : <string | "all", "host">
   * }
   *

   * while reply should the following form
   *

   * {
   *   "type" : "lavi"
   *   "command" : <string | "add", "delete">
   *   "node_type" : "host"
   *   "node_id" : [ <string in hex>, ...]
   * }
   *

   * Note that node_id is only unique per node_type, i.e.,
   * only node_type:node_id is globally unique.
   *
   * @author ykk
   * @date July 2010
   */
  class lavi_hosts
    : public lavi_nodes
  {
  public:
    /** \brief Constructor of lavi_hosts.
     *
     * @param c context
     * @param node XML configuration (JSON object)
     */
    lavi_hosts(const Context* c, const json_object* node)
      : lavi_nodes(c, node)
    {}

    /** \brief Configure lavi_hosts.
     *
     * Parse the configuration, register event handlers, and
     * resolve any dependencies.
     *
     * @param c configuration
     */
    void configure(const Configuration* c);

    /** \brief Function to send list.
     *
     * @param stream message stream to send list to
     */
    void send_list(const Msg_stream& stream);

    /** \brief Start lavi_hosts.
     *
     * Start the component. For example, if any threads require
     * starting, do it now.
     */
    void install();

    /** \brief Handle host changes
     * @param e event
     * @return CONTINUE always
     */
    Disposition handle_host_loc(const Event& e);

    /** \brief Get instance of lavi_hosts.
     * @param c context
     * @param component reference to component
     */
    static void getInstance(const container::Context* c,
			    lavi_hosts*& component);

  private:
    /** \brief Send list of hosts
     * @param stream socket to send list over
     * @param host_list list of host mac address to send
     * @param add indicate if add or delete
     */
    void send_hostlist(const Msg_stream& stream,
		       const list<ethernetaddr> host_list,
		       bool add=true);

    /** \brief Reference to hosttracker
     */
    hosttracker* ht;
  };
}

#endif

ext: hh

max_stars_repo_name: ayjazz/OESS

max_issues_repo_name: ayjazz/OESS

max_forks_repo_name: ayjazz/OESS


text:
/* gc_test.cc
   Jeremy Barnes, 23 February 2010
   Copyright (c) 2010 mldb.ai inc.  All rights reserved.

   This file is part of MLDB. Copyright 2015 mldb.ai inc. All rights reserved.

   Test of the garbage collector locking.
*/

#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK

#include "gc_lock_test_common.h"
#include "mldb/utils/string_functions.h"
#include "mldb/base/exc_assert.h"
#include "mldb/base/scope.h"
#include "mldb/arch/thread_specific.h"
#include "mldb/arch/rwlock.h"
#include "mldb/arch/spinlock.h"
#include "mldb/arch/tick_counter.h"
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <atomic>

using namespace MLDB;
using namespace std;

// Defined in gc_lock.cc
namespace MLDB {
extern int32_t gcLockStartingEpoch;
};

#if 1

BOOST_AUTO_TEST_CASE ( test_gc )
{
    GcLock gc;

    cerr << endl << "before lock" << endl;
    gc.dump();

    gc.lockShared();

    BOOST_CHECK(gc.isLockedShared());

    std::atomic<int> deferred(false);

    cerr << endl << "before defer" << endl;
    gc.dump();

    gc.defer([&] () { deferred = true; });

    cerr << endl << "after defer" << endl;
    gc.dump();

    gc.unlockShared();

    cerr << endl << "after unlock shared" << endl;
    gc.dump();

    BOOST_CHECK(!gc.isLockedShared());
    BOOST_CHECK(deferred);
}

BOOST_AUTO_TEST_CASE(test_mutual_exclusion)
{
    cerr << "testing mutual exclusion" << endl;

    GcLock lock;
    std::atomic<bool> finished(false);
    std::atomic<int> numExclusive(0);
    std::atomic<int> numShared(0);
    std::atomic<int> errors(0);
    std::atomic<int> multiShared(0);
    std::atomic<int> sharedIterations(0);
    std::atomic<uint64_t> exclusiveIterations(0);

    auto sharedThread = [&] ()
        {
            while (!finished) {
                GcLock::SharedGuard guard(lock);
                numShared += 1;

                if (numExclusive > 0) {
                    cerr << "exclusive and shared" << endl;
                    errors += 1;
                }
                if (numShared > 1) {
                    multiShared += 1;
                }

                numShared -= 1;
                sharedIterations += 1;
                std::atomic_thread_fence(std::memory_order_seq_cst);
            }
        };

    auto exclusiveThread = [&] ()
        {
            while (!finished) {
                GcLock::ExclusiveGuard guard(lock);
                numExclusive += 1;

                if (numExclusive > 1) {
                    cerr << "more than one exclusive" << endl;
                    errors += 1;
                }
                if (numShared > 0) {
                    cerr << "exclusive and shared" << endl;
                    multiShared += 1;
                }

                numExclusive -= 1;
                exclusiveIterations += 1;
                std::atomic_thread_fence(std::memory_order_seq_cst);
            }
        };

    lock.getEntry();

    int nthreads = 4;

    {
        cerr << "single shared" << endl;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        tg.emplace_back(sharedThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

    {
        cerr << "multi shared" << endl;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        for (unsigned i = 0;  i < nthreads;  ++i)
            tg.emplace_back(sharedThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        if (nthreads > 1)
            BOOST_CHECK_GE(multiShared, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

    {
        cerr << "single exclusive" << endl;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        tg.emplace_back(exclusiveThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

    {
        cerr << "multi exclusive" << endl;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        for (unsigned i = 0;  i < nthreads;  ++i)
            tg.emplace_back(exclusiveThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

    {
        cerr << "mixed shared and exclusive" << endl;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        for (unsigned i = 0;  i < nthreads;  ++i)
            tg.emplace_back(sharedThread);
        for (unsigned i = 0;  i < nthreads;  ++i)
            tg.emplace_back(exclusiveThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        if (nthreads > 1)
            BOOST_CHECK_GE(multiShared, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

    {
        cerr << "overflow" << endl;
        gcLockStartingEpoch = 0xFFFFFFF0;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        tg.emplace_back(sharedThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

    {
        cerr << "INT_MIN to INT_MAX" << endl;
        gcLockStartingEpoch = 0x7FFFFFF0;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        tg.emplace_back(sharedThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

    {
        cerr << "benign overflow" << endl;
        gcLockStartingEpoch = 0xBFFFFFF0;
        sharedIterations = exclusiveIterations = multiShared = finished = 0;
        ThreadGroup tg;
        tg.emplace_back(sharedThread);
        sleep(1);
        finished = true;
        tg.join_all();
        BOOST_CHECK_EQUAL(errors, 0);
        cerr << "iterations: shared " << sharedIterations
             << " exclusive " << exclusiveIterations << endl;
        cerr << "multiShared = " << multiShared << endl;
    }

}

#endif

#if 1
BOOST_AUTO_TEST_CASE ( test_gc_sync_many_threads_contention )
{
    cerr << "testing contention synchronized GcLock with many threads" << endl;

    int nthreads = 8;
    int nSpinThreads = 16;
    int nblocks = 2;

    TestBase<GcLock> test(nthreads, nblocks, nSpinThreads);
    test.run(std::bind(&TestBase<GcLock>::allocThreadSync, &test,
                       std::placeholders::_1));
}
#endif

BOOST_AUTO_TEST_CASE ( test_gc_deferred_contention )
{
    cerr << "testing contended deferred GcLock" << endl;

    int nthreads = 8;
    int nSpinThreads = 0;//16;
    int nblocks = 2;

    TestBase<GcLock> test(nthreads, nblocks, nSpinThreads);
    test.run(std::bind(&TestBase<GcLock>::allocThreadDefer, &test,
                       std::placeholders::_1));
}

#if 1

BOOST_AUTO_TEST_CASE ( test_gc_sync )
{
    cerr << "testing synchronized GcLock" << endl;

    int nthreads = 2;
    int nblocks = 2;

    TestBase<GcLock> test(nthreads, nblocks);
    test.run(std::bind(&TestBase<GcLock>::allocThreadSync, &test,
                       std::placeholders::_1));
}

BOOST_AUTO_TEST_CASE ( test_gc_sync_many_threads )
{
    cerr << "testing synchronized GcLock with many threads" << endl;

    int nthreads = 8;
    int nblocks = 2;

    TestBase<GcLock> test(nthreads, nblocks);
    test.run(std::bind(&TestBase<GcLock>::allocThreadSync, &test,
                       std::placeholders::_1));
}

BOOST_AUTO_TEST_CASE ( test_gc_deferred )
{
    cerr << "testing deferred GcLock" << endl;

    int nthreads = 2;
    int nblocks = 2;

    TestBase<GcLock> test(nthreads, nblocks);
    test.run(std::bind(&TestBase<GcLock>::allocThreadDefer, &test,
                       std::placeholders::_1));
}

BOOST_AUTO_TEST_CASE ( test_defer_race )
{
    cerr << "testing defer race" << endl;
    GcLock gc;

    ThreadGroup tg;

    volatile bool finished = false;

    int nthreads = 0;

    std::atomic<int> numStarted(0);

    auto doTestThread = [&] ()
        {
            while (!finished) {
                numStarted += 1;
                while (numStarted != nthreads) ;

                gc.deferBarrier();

                numStarted -= 1;
                while (numStarted != 0) ;
            }
        };

    for (unsigned i = 0;  i < nthreads;  ++i)
        tg.emplace_back(doTestThread);

    int runTime = 1;

    sleep(runTime);

    finished = true;

    tg.join_all();
}

#endif

ext: cc

max_stars_repo_name: kstepanmpmg/mldb

max_issues_repo_name: tomzhang/mldb

max_forks_repo_name: matebestek/mldb


text:
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "test_conv2d"

#include <boost/test/unit_test.hpp>
#include "nanocv/tensor.h"
#include "nanocv/logger.h"
#include "nanocv/math/close.hpp"
#include "nanocv/math/conv2d.hpp"
#include "nanocv/math/epsilon.hpp"

namespace test
{
        using namespace ncv;

        template
        <
                typename top,
                typename tmatrix,
                typename tscalar = typename tmatrix::Scalar
        >
        tscalar test_cpu(top op, const tmatrix& idata, const tmatrix& kdata, tmatrix& odata)
        {
                odata.setZero();

                op(idata, kdata, odata);

                return odata.sum();
        }

        void test_conv2d(int isize, int ksize)
        {
                const int osize = isize - ksize + 1;

                matrix_t idata(isize, isize);
                matrix_t kdata(ksize, ksize);
                matrix_t odata(osize, osize);

                idata.setRandom();
                kdata.setRandom();
                odata.setRandom();

                idata /= isize;
                kdata /= ksize;
                odata /= osize;

                const scalar_t convcpu_eig = test_cpu(ncv::math::conv2d_eig<matrix_t>, idata, kdata, odata);
                const scalar_t convcpu_cpp = test_cpu(ncv::math::conv2d_cpp<matrix_t>, idata, kdata, odata);
                const scalar_t convcpu_dot = test_cpu(ncv::math::conv2d_dot<matrix_t>, idata, kdata, odata);
                const scalar_t convcpu_mad = test_cpu(ncv::math::conv2d_mad<matrix_t>, idata, kdata, odata);
                const scalar_t convcpu_dyn = test_cpu(ncv::math::conv2d_dyn<matrix_t>, idata, kdata, odata);

                const scalar_t epsilon = math::epsilon1<scalar_t>();

                BOOST_CHECK_LE(math::abs(convcpu_eig - convcpu_eig), epsilon);
                BOOST_CHECK_LE(math::abs(convcpu_cpp - convcpu_eig), epsilon);
                BOOST_CHECK_LE(math::abs(convcpu_dot - convcpu_eig), epsilon);
                BOOST_CHECK_LE(math::abs(convcpu_mad - convcpu_eig), epsilon);
                BOOST_CHECK_LE(math::abs(convcpu_dyn - convcpu_eig), epsilon);
        }
}

BOOST_AUTO_TEST_CASE(test_conv2d)
{
        using namespace ncv;

        const int min_isize = 24;
        const int max_isize = 48;
        const int min_ksize = 5;
        const int n_tests = 64;

        for (int isize = min_isize; isize <= max_isize; isize += 4)
        {
                for (int ksize = min_ksize; ksize <= isize - min_ksize; ksize += 2)
                {
                        for (int t = 0; t < n_tests; t ++)
                        {
                                test::test_conv2d(isize, ksize);
                        }
                }
        }
}

ext: cpp


text:
#pragma once
#include <NTL.hpp>

cl_float3 glmVec3toClFloat3(glm::vec3 vec);
cl_float4 glmVec4toClFloat4(glm::vec4 vec);
cl_float3 makeFloat3(float x, float y, float z);


text:
/*
* This file is part of ATLAS. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this distribution.
* (Also avialable at http://www.apache.org/licenses/LICENSE-2.0.txt)
* You may not use this file except in compliance with the License.
*/
#include <fstream>
#include <iostream>
#include <boost/filesystem/operations.hpp>
#include <boost/program_options.hpp>
#include <boost/exception/all.hpp>
#include "configuration.hpp"

namespace bpo = boost::program_options;

namespace AssimpWorker {

Configuration* Configuration::singletonInstance = nullptr;
const char* Configuration::defaultConfigFilename = "assimpworker.conf";

Configuration& Configuration::getInstance() {
	if (singletonInstance == nullptr) {
		singletonInstance = new Configuration();
	}
	return *singletonInstance;
}

Configuration::Configuration()
{
	setupOptions();
	parseConfigFile();
}

void Configuration::init(int argc, char **argv) {
	try {
		bpo::command_line_parser parser(argc, argv);
		parser.options(description);
		bpo::store(parser.run(),parsedVariables);
		// in case the default file didn't exist
		// and we now know a non-default name:
		parseConfigFile();
		if (parsedVariables.count("help") || parsedVariables.count("version")) {
			// if these are defined, skip checks, should exit from main anyway.
			return;
		}
		// now that we have parsed commandline
		// as well as default and possibly other configfile
		// check for missing stuff:
		bpo::notify(parsedVariables);
	} catch (std::exception const& e) {
		std::cerr << "Parsing options: " << e.what() << std::endl;
		exit(1);
	}
}

void Configuration::parseConfigFile() {
	const char* configFileName = nullptr;
	if (parsedVariables.count("config")) {
		// config file specified
		std::string configFile = parsedVariables["config"].as<std::string>();
		configFileName = configFile.c_str();
	} else if (defaultConfigExists()) {
		configFileName = defaultConfigFilename;
	}
	if (!configFileName){
		return;
	}
	std::ifstream configFile(configFileName);
	if (configFile.good()) {
		bpo::parsed_options parsedConfig = bpo::parse_config_file(configFile,description);
		bpo::store(parsedConfig, parsedVariables);
	}
	// don't notify here, as we may not have parsed commandline yet.
}

bool Configuration::defaultConfigExists() {
	return boost::filesystem::exists(defaultConfigFilename);
}

void Configuration::setupOptions() {
	bpo::options_description basic("Basic options");
	basic.add_options()
		("help,h,?", "show this message")
		("version,v","show version number")
		("config,c", bpo::value<std::string>(), "read configuration from file, overrides options given on command line")
		("decompression-path", bpo::value<std::string>()->default_value("./tmp"), "Path to temporary space for decompressed zip contents")
	;
	bpo::options_description import("Import options");
	import.add_options()
		("mesh-split", "Split meshes larger than a certain number of vertices.")
		("mesh-split-threshold", bpo::value<int>()->default_value(65535), "Number of vertices at which to split.")
	;
	bpo::options_description stomp("Stomp options");
	stomp.add_options()
		("stomp-heartbeat-interval-ms", bpo::value<int>()->default_value(10000), "Heartbeat interval in ms")
		("stomp-port", bpo::value<int>()        ->default_value(61613),              "Server port (STOMP protocol)")
		("stomp-host", bpo::value<std::string>()->default_value("localhost"),        "Server address")
		("stomp-user", bpo::value<std::string>()->required(),                        "Username")
		("stomp-pass", bpo::value<std::string>()->required(),                        "Password")
		("work-queue",bpo::value<std::string>()->default_value("atlas.work.import"),"Work queue name")
		("feedback-queue",bpo::value<std::string>()->default_value("atlas.work.feedback"),"Feedback queue name")
	;
	bpo::options_description jcr("Repository options");
	jcr.add_options()
		("jcr-url",
		 bpo::value<std::string>()->default_value("http://localhost:8080/modeshape-rest/atlas/default/"),
		 "Root URL")
		("jcr-user",
		 bpo::value<std::string>()->default_value("admin"),
		 "Username")
		("jcr-pass",
		 bpo::value<std::string>()->default_value("admin"),
		 "Password")
	;

	description.add(basic);
	description.add(import);
	description.add(stomp);
	description.add(jcr);
}

const bpo::variable_value& Configuration::get(const std::string &entry) const {
	return parsedVariables[entry];
}

const bool Configuration::enabled(const std::string& entry) const
{
	return parsedVariables.count(entry);
}

void Configuration::printDescription() const
{
	std::cout << description << std::endl;
}

}

max_stars_repo_name: dfki-asr/atlas-worker

max_issues_repo_name: dfki-asr/atlas-worker

max_forks_repo_name: dfki-asr/atlas-worker


text:
#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpServer.h>
#include <boost/bind.hpp>
#include <list>
#include <stdio.h>

using namespace muduo;
using namespace muduo::net;

// RFC 862
class EchoServer
{
 public:
  EchoServer(EventLoop* loop,
             const InetAddress& listenAddr,
             int idleSeconds);

  void start()
  {
    server_.start();
  }

 private:
  void onConnection(const TcpConnectionPtr& conn);

  void onMessage(const TcpConnectionPtr& conn,
                 Buffer* buf,
                 Timestamp time);

  void onTimer();

  void dumpConnectionList() const;

  typedef boost::weak_ptr<TcpConnection> WeakTcpConnectionPtr;
  typedef std::list<WeakTcpConnectionPtr> WeakConnectionList;

  struct Node : public muduo::copyable
  {
    Timestamp lastReceiveTime;
    WeakConnectionList::iterator position;
  };

  TcpServer server_;
  int idleSeconds_;
  WeakConnectionList connectionList_;
};

EchoServer::EchoServer(EventLoop* loop,
                       const InetAddress& listenAddr,
                       int idleSeconds)
  : server_(loop, listenAddr, "EchoServer"),
    idleSeconds_(idleSeconds)
{
  server_.setConnectionCallback(
      boost::bind(&EchoServer::onConnection, this, _1));
  server_.setMessageCallback(
      boost::bind(&EchoServer::onMessage, this, _1, _2, _3));
  loop->runEvery(1.0, boost::bind(&EchoServer::onTimer, this));
  dumpConnectionList();
}

void EchoServer::onConnection(const TcpConnectionPtr& conn)
{
  LOG_INFO << "EchoServer - " << conn->peerAddress().toIpPort() << " -> "
           << conn->localAddress().toIpPort() << " is "
           << (conn->connected() ? "UP" : "DOWN");

  if (conn->connected())
  {
    Node node;
    node.lastReceiveTime = Timestamp::now();
    connectionList_.push_back(conn);
    node.position = --connectionList_.end();
    conn->setContext(node);
  }
  else
  {
    assert(!conn->getContext().empty());
    const Node& node = boost::any_cast<const Node&>(conn->getContext());
    connectionList_.erase(node.position);
  }
  dumpConnectionList();
}

void EchoServer::onMessage(const TcpConnectionPtr& conn,
                           Buffer* buf,
                           Timestamp time)
{
  string msg(buf->retrieveAllAsString());
  LOG_INFO << conn->name() << " echo " << msg.size()
           << " bytes at " << time.toString();
  conn->send(msg);

  assert(!conn->getContext().empty());
  Node* node = boost::any_cast<Node>(conn->getMutableContext());
  node->lastReceiveTime = time;
  // move node inside list with list::splice()
  connectionList_.erase(node->position);
  connectionList_.push_back(conn);
  node->position = --connectionList_.end();

  dumpConnectionList();
}

void EchoServer::onTimer()
{
  dumpConnectionList();
  Timestamp now = Timestamp::now();
  for (WeakConnectionList::iterator it = connectionList_.begin();
      it != connectionList_.end();)
  {
    TcpConnectionPtr conn = it->lock();
    if (conn)
    {
      Node* n = boost::any_cast<Node>(conn->getMutableContext());
      double age = timeDifference(now, n->lastReceiveTime);
      if (age > idleSeconds_)
      {
        conn->shutdown();
      }
      else if (age < 0)
      {
        LOG_WARN << "Time jump";
        n->lastReceiveTime = now;
      }
      else
      {
        break;
      }
      ++it;
    }
    else
    {
      LOG_WARN << "Expired";
      it = connectionList_.erase(it);
    }
  }
}

void EchoServer::dumpConnectionList() const
{
  LOG_INFO << "size = " << connectionList_.size();

  for (WeakConnectionList::const_iterator it = connectionList_.begin();
      it != connectionList_.end(); ++it)
  {
    TcpConnectionPtr conn = it->lock();
    if (conn)
    {
      printf("conn %p\n", get_pointer(conn));
      const Node& n = boost::any_cast<const Node&>(conn->getContext());
      printf("    time %s\n", n.lastReceiveTime.toString().c_str());
    }
    else
    {
      printf("expired\n");
    }
  }
}

int main(int argc, char* argv[])
{
  EventLoop loop;
  InetAddress listenAddr(2007);
  int idleSeconds = 10;
  if (argc > 1)
  {
    idleSeconds = atoi(argv[1]);
  }
  LOG_INFO << "pid = " << getpid() << ", idle seconds = " << idleSeconds;
  EchoServer server(&loop, listenAddr, idleSeconds);
  server.start();
  loop.loop();
}

max_stars_repo_name: maydayzm/muduo

max_issues_repo_name: maydayzm/muduo

max_forks_repo_name: maydayzm/muduo


text:
#ifndef INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CLOSE_STATEMENT_HPP_
#define INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CLOSE_STATEMENT_HPP_

#include <boost/asio/bind_executor.hpp>
#include <boost/asio/async_result.hpp>
#include "boost/mysql/detail/protocol/prepared_statement_messages.hpp"

template <typename StreamType>
void boost::mysql::detail::close_statement(
	channel<StreamType>& chan,
	std::uint32_t statement_id,
	error_code& code,
	error_info&
)
{
	// Compose the close message
	com_stmt_close_packet packet {int4(statement_id)};

	// Serialize it
	serialize_message(packet, chan.current_capabilities(), chan.shared_buffer());

	// Send it. No response is sent back
	chan.reset_sequence_number();
	chan.write(boost::asio::buffer(chan.shared_buffer()), code);
}

template <typename StreamType, typename CompletionToken>
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(boost::mysql::error_code, boost::mysql::error_info))
boost::mysql::detail::async_close_statement(
	channel<StreamType>& chan,
	std::uint32_t statement_id,
	CompletionToken&& token
)
{
	// Compose the close message
	com_stmt_close_packet packet {int4(statement_id)};

	// Serialize it
	serialize_message(packet, chan.current_capabilities(), chan.shared_buffer());

	// Send it. No response is sent back
	chan.reset_sequence_number();

	auto initiation = [](
		auto&& completion_handler,
		channel<StreamType>& chan
	)
	{
		// Executor to use
		auto executor = boost::asio::get_associated_executor(
			completion_handler,
			chan.next_layer().get_executor()
		);

		// Preserve the executor to use
		chan.async_write(
			boost::asio::buffer(chan.shared_buffer()),
			boost::asio::bind_executor(
				executor,
				std::bind(
					std::forward<decltype(completion_handler)>(completion_handler),
					std::placeholders::_1,
					error_info()
				)
			)
		);
	};

	return boost::asio::async_initiate<CompletionToken, void(error_code, error_info)>(
			initiation, token, chan);
}

#endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CLOSE_STATEMENT_HPP_ */


text:
/*
	Copyright (C) 2003-2013 by David White <davewx7@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MODULE_HPP_INCLUDED
#define MODULE_HPP_INCLUDED

#include <boost/scoped_ptr.hpp>

#include "filesystem.hpp"
#include "formula_callable.hpp"
#include "variant.hpp"

#include <map>
#include <string>
#include <vector>

namespace graphics {
	class color;
}

namespace module {

enum BASE_PATH_TYPE { BASE_PATH_GAME, BASE_PATH_USER, NUM_PATH_TYPES };

struct modules {
	std::string name_;
	std::string pretty_name_;
	std::string abbreviation_;

	//base_path_ is in the game data directory, user_path_ is in the user's
	//preferences area and is mutable.
	std::string base_path_[NUM_PATH_TYPES];

	std::string default_font;
	std::string default_font_cjk;

	boost::intrusive_ptr<graphics::color> speech_dialog_bg_color;

	std::vector<int> version_;
	std::vector<std::string> included_modules_;

	variant default_preferences;
};

typedef std::map<std::string, std::string> module_file_map;
typedef std::pair<std::string, std::string> module_file_pair;
typedef std::map<std::string, std::string>::const_iterator module_file_map_iterator;

//sets the core module name we are using. This MUST be called before
//using any other module functions to establish the dlc path we use.
void set_core_module_name(const std::string& module_name);

const std::string get_module_name();
const std::string get_module_pretty_name();
std::string get_module_version();
std::string map_file(const std::string& fname);

std::string get_default_font();
const boost::intrusive_ptr<graphics::color>& get_speech_dialog_bg_color();

variant get_default_preferences();

enum MODULE_PREFIX_BEHAVIOR { MODULE_PREFIX, MODULE_NO_PREFIX };
void get_unique_filenames_under_dir(const std::string& dir,
                                    std::map<std::string, std::string>* file_map,
									MODULE_PREFIX_BEHAVIOR prefix=MODULE_PREFIX);

void get_files_in_dir(const std::string& dir,
                      std::vector<std::string>* files,
                      std::vector<std::string>* dirs=NULL);

void get_files_matching_wildcard(const std::string& pattern,
                                 std::string* dir_out,
                                 std::vector<std::string>* files);

std::string get_id(const std::string& id);
std::string get_module_id(const std::string& id);
std::string make_module_id(const std::string& name);
std::map<std::string, std::string>::const_iterator find(const std::map<std::string, std::string>& filemap, const std::string& name);
const std::string& get_module_path(const std::string& abbrev="", BASE_PATH_TYPE type=BASE_PATH_GAME);
std::vector<variant> get_all();
variant get(const std::string& name);
void load(const std::string& name, bool initial=true);
void reload(const std::string& name);
void get_module_list(std::vector<std::string>& dirs);
void load_module_from_file(const std::string& modname, modules* mod_);
void write_file(const std::string& mod_path, const std::string& data);

variant build_package(const std::string& id);

bool uninstall_downloaded_module(const std::string& id);

void set_module_args(game_logic::const_formula_callable_ptr callable);
game_logic::const_formula_callable_ptr get_module_args();

class client : public game_logic::formula_callable
{
public:
	client();
	client(const std::string& host, const std::string& port);

	//function which downloads a module and has it ready to install but
	//doesn't install it yet.
	void prepare_install_module(const std::string& module_name, bool force=false);

	//completes installation of a module after previously calling
	//prepare_install_module(). pre-condition: module_prepared() returns true
	void complete_install_module();

	//returns true iff we called prepare_install_module() previously and now
	//the module is fully downloaded and ready to install.
	bool module_prepared() const;

	//begins download and installation of a given module.
	void install_module(const std::string& module_name, bool force=false);
	void rate_module(const std::string& module_id, int rating, const std::string& review);
	void get_status();
	bool process();
	const std::string& error() const { return error_; }
	variant get_value(const std::string& key) const;

	int nbytes_transferred() const { return nbytes_transferred_; }
	int nbytes_total() const { return nbytes_total_; }
	int nfiles_written() const { return nfiles_written_; }

	void set_install_image(bool value) { install_image_ = value; }
private:
	enum OPERATION_TYPE { OPERATION_NONE, OPERATION_INSTALL, OPERATION_PREPARE_INSTALL, OPERATION_GET_STATUS, OPERATION_GET_ICONS, OPERATION_RATE };
	OPERATION_TYPE operation_;
	std::string module_id_;
	std::string error_;
	boost::scoped_ptr<class http_client> client_;

	std::map<std::string, variant> data_;
	variant module_info_;

	int nbytes_transferred_, nbytes_total_;

	int nfiles_written_;

	bool install_image_;

	//a response that is ready for installation. Only used when operation_ is
	//OPERATION_PREPARE_INSTALL
	std::string pending_response_;

	void on_response(std::string response);
	void on_error(std::string response);
	void on_progress(int sent, int total, bool uploaded);

	void perform_install(const std::string& response);
};

}

#endif

max_stars_repo_name: sweetkristas/anura

max_issues_repo_name: sweetkristas/anura

max_forks_repo_name: sweetkristas/anura


text:
#ifndef HERMIT_STREAM_NATIVE_PACK_NATIVE_PACK_BASE_NATIVE_PACK_BASE_HPP
#define HERMIT_STREAM_NATIVE_PACK_NATIVE_PACK_BASE_NATIVE_PACK_BASE_HPP

#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/mpl/or.hpp>
#include <hermit/stream/native_pack_size.hpp>

namespace hermit {
  namespace stream {
    template<
      typename T,
      size_t size = native_pack_size< T >::value,
      bool is_pod = boost::mpl::or_< boost::is_integral< T >, boost::is_float< T > >::value
    >
    struct native_pack {};
  }
}

#endif

max_stars_repo_name: Fadis/hermit

max_issues_repo_name: Fadis/hermit

max_forks_repo_name: Fadis/hermit