Ejemplo n.º 1
0
void sctpServer::stop()
{
    sc_memory_shutdown();

    mEventManager->shutdown();
    delete mEventManager;
    mEventManager = 0;

    close();
}
Ejemplo n.º 2
0
void ScMemory::shutdown(bool saveState /* = true */)
{
    if (msContexts.size() > 0)
    {
        std::stringstream description;
        description << "There are " << msContexts.size() << " contexts, wan't destroyed, before Memory::shutdown:";
        tMemoryContextList::const_iterator it = msContexts.begin();
        for (; it != msContexts.end(); ++it)
            description << "\t\n" << (*it)->getName();

        error(description.str());
    }

    sc_memory_shutdown(SC_BOOL(saveState));
    msGlobalContext = 0;

	g_log_set_default_handler(g_log_default_handler, nullptr);
}
Ejemplo n.º 3
0
void test_combined_creation()
{
    int thread_count = g_thread_count;
    int test_count = (g_task_count) / thread_count;

    g_message("Threads count: %d, Test per thread: %d", thread_count, test_count);

    tGThreadVector threads;
    threads.reserve(thread_count);

    s_default_ctx = sc_memory_initialize(&params);
    print_storage_statistics();    

    g_test_timer_start();
    for (size_t i = 0; i < thread_count; ++i)
    {
        GThreadFunc f = create_node_thread;
        switch(g_random_int() % 3)
        {
        case 0:
            f = create_link_thread;
            break;
        case 1:
            f = create_arc_thread;
            break;
        default:
            break;
        }

        GThread * thread = g_thread_try_new(0, f, GINT_TO_POINTER(test_count), 0);
        if (thread == 0)
            continue;
        threads.push_back(thread);
    }

    for (size_t i = 0; i < thread_count; ++i)
        g_assert(GPOINTER_TO_INT(g_thread_join(threads[i])) == test_count);

    printf("Time: %lf\n", g_test_timer_elapsed());

    print_storage_statistics();
    sc_memory_shutdown(SC_FALSE);
}
Ejemplo n.º 4
0
void test_save()
{
    // create nodes
    s_default_ctx = sc_memory_initialize(&params);

    sc_memory_context *ctx = sc_memory_context_new(sc_access_lvl_make(8, 8));
    int const count = 1000000;
    for (int i = 0; i < count; ++i)
    {
        g_assert(SC_ADDR_IS_NOT_EMPTY(sc_memory_node_new(ctx, 0)));
    }

    sc_memory_context_free(ctx);

    GThread * thread = g_thread_try_new(0, start_save_threaded, 0, 0);
    test_creation(create_arc_thread, g_task_count, g_thread_count);

    g_thread_join(thread);

    sc_memory_shutdown(SC_FALSE);
}
Ejemplo n.º 5
0
bool Builder::run(const BuilderParams &params)
{

    mParams = params;

    collectFiles();

    // initialize sc-memory
    sc_memory_params p;
    sc_memory_params_clear(&p);
    p.clear = mParams.clearOutput ? SC_TRUE : SC_FALSE;
    p.config_file = mParams.configFile.empty() ? 0 : mParams.configFile.c_str();
    p.repo_path = mParams.outputPath.c_str();
    p.ext_path = mParams.extensionsPath.size() > 0 ? mParams.extensionsPath.c_str() : 0;

    sc_memory_initialize(&p);

    mContext = sc_memory_context_new(sc_access_lvl_make_min);

    std::cout << "Build knowledge base from sources... " << std::endl;

    // process founded files
    uint32 done = 0, last_progress = -1;
    tFileSet::iterator it, itEnd = mFileSet.end();
    for (it = mFileSet.begin(); it != itEnd; ++it)
    {
        uint32 progress = (uint32)(((float)++done / (float)mFileSet.size()) * 100);
        if (mParams.showFileNames)
        {
            std::cout << "[ " << progress << "% ] " << *it << std::endl;
        }
        else
        {
            if (last_progress != progress)
            {
                if (progress % 10 == 0)
                {
                    std::cout << "[" << progress << "%]";
                    std::cout.flush();
                }
                else
                {
                    std::cout << ".";
                    std::cout.flush();
                }
                last_progress = progress;
            }
        }

        try
        {
            processFile(*it);
        } catch(const Exception &e)
        {
            StringStream ss;
            ss << e.getDescription() << " in " << e.getFileName() << " at line " << e.getLineNumber();
            mErrors.push_back(ss.str());
        }
    }
    std::cout << std::endl << "done" << std::endl;

    // print errors
    std::cout << std::endl << "-------" << std::endl << "Errors:" << std::endl;
    int idx = 1;
    tStringList::iterator itErr, itErrEnd = mErrors.end();
    for (itErr = mErrors.begin(); itErr != itErrEnd; ++itErr)
        std::cout << "[" << idx++ << "]\t" << *itErr << std::endl;

    // print statistics
    sc_stat stat;
    sc_memory_stat(mContext, &stat);

    unsigned int all_count = stat.arc_count + stat.node_count + stat.link_count;

    std::cout << std::endl << "Statistics" << std::endl;
    std::cout << "Nodes: " << stat.node_count << "(" << ((float)stat.node_count / (float)all_count) * 100 << "%)" << std::endl;
    std::cout << "Arcs: " << stat.arc_count << "(" << ((float)stat.arc_count / (float)all_count) * 100 << "%)"  << std::endl;
    std::cout << "Links: " << stat.link_count << "(" << ((float)stat.link_count / (float)all_count) * 100 << "%)"  << std::endl;
    std::cout << "Total: " << all_count << std::endl;

    sc_memory_context_free(mContext);
    sc_memory_shutdown(SC_TRUE);

    return true;
}
Ejemplo n.º 6
0
void sctpServer::stop()
{
    sc_memory_shutdown();
    close();
}
Ejemplo n.º 7
0
void test_link_creation()
{
    s_default_ctx = sc_memory_initialize(&params);
    test_creation(create_link_thread, g_task_count, g_thread_count);
    sc_memory_shutdown(SC_FALSE);
}