Beispiel #1
0
sam::mfu sam::getListOfFiles(os::Path p, bool dot)
{
    static ull sz = 0;

    string pstr = p.str();
    string prefix = pstr + '/';
    if (pstr.empty()) never(1);
    if (pstr == ".") prefix = "";

    mfu r;
    os::Dir d = os::FileSys::readDirEx(p, true, true);

    sz += d.files.size();
    cout << sz << '\r' << std::flush;

    for ( auto f : d.files )
    {
        if ( !dot && f.first[0] == '.' ) continue;
        string n = prefix + f.first;
        r[File {prefix, f.first, os::FileSys::mtime(n), ull(f.second)}] = f.second;
    }
    for ( auto f : d.dirs )
    {
        if ( !dot && f[0] == '.' ) continue;
        auto n = getListOfFiles(prefix + f, dot);
        r.insert(n.begin(), n.end());
    }

    return r;
}
void LongLongTestCase::LoHi()
{
    wxLongLong ll(123, 456);
    CPPUNIT_ASSERT_EQUAL( 456u, ll.GetLo() );
    CPPUNIT_ASSERT_EQUAL( 123, ll.GetHi() );

    wxULongLong ull(987, 654);
    CPPUNIT_ASSERT_EQUAL( 654u, ull.GetLo() );
    CPPUNIT_ASSERT_EQUAL( 987u, ull.GetHi() );
}
Beispiel #3
0
    bool one_size_heap_list::did_alloc(void* p) const
    {
        unique_lock_type ul(mtx_);
        for (typename list_type::value_type const& heap : heap_list_)
        {
            bool did_allocate = false;

            {
                util::unlock_guard<unique_lock_type> ull(ul);
                did_allocate = heap->did_alloc(p);
            }

            if (did_allocate)
                return true;
        }
        return false;
    }
Beispiel #4
0
        bool did_alloc(void* p) const
        {
            unique_lock_type ul(mtx_);
            for (const_iterator it = heap_list_.begin(); it != heap_list_.end(); ++it)
            {
                typename list_type::value_type heap = *it;
                bool did_allocate = false;

                {
                    util::scoped_unlock<unique_lock_type> ull(ul);
                    did_allocate = heap->did_alloc(p);
                }

                if (did_allocate)
                    return true;
            }
            return false;
        }
Beispiel #5
0
    void one_size_heap_list::free(void* p, std::size_t count)
    {
        unique_lock_type ul(mtx_);

        if (nullptr == p || !threads::threadmanager_is(state_running))
            return;

        // if this is called from outside a HPX thread we need to
        // re-schedule the request
        if (reschedule(p, count))
            return;

        // Find the heap which allocated this pointer.
        for (auto & heap : heap_list_)
        {
            bool did_allocate = false;

            {
                util::unlock_guard<unique_lock_type> ull(ul);
                did_allocate = heap->did_alloc(p);
                if (did_allocate)
                    heap->free(p, count);
            }

            if (did_allocate)
            {
#if defined(HPX_DEBUG)
                free_count_ += count;
#endif
                return;
            }
        }

        ul.unlock();

        HPX_THROW_EXCEPTION(bad_parameter,
            name() + "::free",
            hpx::util::format(
                "pointer {1} was not allocated by this {2}",
                p, name()));
    }
Beispiel #6
0
        void free(void* p, std::size_t count = 1)
        {
            unique_lock_type ul(mtx_);

            if (NULL == p || !threads::threadmanager_is(running))
                return;

            // if this is called from outside a HPX thread we need to
            // re-schedule the request
            if (reschedule(p, count))
                return;

            // Find the heap which allocated this pointer.
            for (iterator it = heap_list_.begin(); it != heap_list_.end(); ++it)
            {
                typename list_type::value_type heap = *it;
                bool did_allocate = false;

                {
                    util::scoped_unlock<unique_lock_type> ull(ul);
                    did_allocate = heap->did_alloc(p);
                    if (did_allocate)
                        heap->free(p, count);
                }

                if (did_allocate)
                {
#if defined(HPX_DEBUG)
                    free_count_ += count;
#endif
                    return;
                }
            }

            HPX_THROW_EXCEPTION(bad_parameter,
                name() + "::free",
                boost::str(boost::format(
                    "pointer %1% was not allocated by this %2%")
                    % p % name()));
        }
Beispiel #7
0
        void create_thread_object(threads::thread_id_type& thrd,
            threads::thread_init_data& data, thread_state_enum state, Lock& lk)
        {
            HPX_ASSERT(lk.owns_lock());
            HPX_ASSERT(data.stacksize != 0);

            std::ptrdiff_t stacksize = data.stacksize;

            std::list<thread_id_type>* heap = 0;

            if (stacksize == get_stack_size(thread_stacksize_small))
            {
                heap = &thread_heap_small_;
            }
            else if (stacksize == get_stack_size(thread_stacksize_medium))
            {
                heap = &thread_heap_medium_;
            }
            else if (stacksize == get_stack_size(thread_stacksize_large))
            {
                heap = &thread_heap_large_;
            }
            else if (stacksize == get_stack_size(thread_stacksize_huge))
            {
                heap = &thread_heap_huge_;
            }
            else {
                switch(stacksize) {
                case thread_stacksize_small:
                    heap = &thread_heap_small_;
                    break;

                case thread_stacksize_medium:
                    heap = &thread_heap_medium_;
                    break;

                case thread_stacksize_large:
                    heap = &thread_heap_large_;
                    break;

                case thread_stacksize_huge:
                    heap = &thread_heap_huge_;
                    break;

                default:
                    break;
                }
            }
            HPX_ASSERT(heap);

            // Check for an unused thread object.
            if (!heap->empty())
            {
                // Take ownership of the thread object and rebind it.
                thrd = heap->front();
                heap->pop_front();
                thrd->rebind(data, state);
            }

            else
            {
                hpx::util::unlock_guard<Lock> ull(lk);

                // Allocate a new thread object.
                thrd = threads::thread_data::create(
                    data, memory_pool_, state);
            }
        }
Beispiel #8
0
template<typename ... T> constexpr ull permutation(T... x) { return ull(sizeof...(T)) + 0x10* make_perm_impl(x...); }