Пример #1
0
int main(int argc, char** argv) {
	int EXITCODE = 0;

	RandomDice* rd = new RandomDice();
	
	DirectionSolver* dds = new Solver(rd);

	WebClient wcl(dds);
	try {
		wcl.run("ws://tetrisj.jvmhost.net:12270/codenjoy-contest/ws", yourName);
	} catch (const std::runtime_error& ex) {
		std::cout << "Runtime error happened: " << ex.what() << std::endl;
		EXITCODE = 1;
	} catch (const std::invalid_argument& iarex) {
		std::cout << "Invalid argument: " << iarex.what() << std::endl;
		EXITCODE = 2;
	} catch (websocketpp::lib::error_code e) {
		std::cout << e.message() << std::endl;
	} catch (...) {
		std::cout << "Something's definitely not right..." << std::endl;
		EXITCODE = 3;
	}
	std::cout << "Done";
	std::cin.get();

	delete dds;
	delete rd;

	return EXITCODE;
}
Пример #2
0
// In Windows, wmain() is an alternate entry point for main(), and receives the same parameters
// as main() but encoded in Windows Unicode (UTF-16); "wide" 16-bit wchar_t characters.  The
// WindowsCommandLine object converts these wide character strings to a UTF-8 coded equivalent
// and makes them available through the argv() and envp() members.  This enables dbtestsMain()
// to process UTF-8 encoded arguments and environment variables without regard to platform.
int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
    WindowsCommandLine wcl(argc, argvW, envpW);
    int exitCode = dbtestsMain(argc, wcl.argv(), wcl.envp());
    ::_exit(exitCode);
}
Пример #3
0
void WorkerCrashLogger::
        test()
{
    // It should fetch information asynchronously of crashed workers.
    {
        DEBUG TaskInfo ti("Catch info from a previously crashed worker");

        std::string name = "WorkerCrashLogger1";
        int argc = 1;
        char * argv = &name[0];
        QApplication a(argc,&argv);

        //for (int consume=0; consume<2; consume++)
        ISchedule::ptr schedule(new DummyScheduler);
        Bedroom::ptr bedroom(new Bedroom);
        Workers::ptr workers(new Workers(IWorkerFactory::ptr(new QtEventWorkerFactory(schedule, bedroom))));

        {
            WorkerCrashLogger wcl(workers);
        }

        // Catch info from a previously crashed worker
        addAndWaitForStop(workers);
        addAndWaitForStop(workers);

        {
            TRACE_PERF("Init");

            WorkerCrashLogger wcl(workers);
            a.processEvents (); // Init new thread before telling it to quit

            // When the thread quits. Wait for the beautifier to log everything.
        }

        // Should have consumed all workers
        Workers::DeadEngines de = workers.write ()->clean_dead_workers();
        EXCEPTION_ASSERT_EQUALS(de.size (), 0u);
    }

    {
        DEBUG TaskInfo ti("Catch info from a crashed worker as it happens");

        std::string name = "WorkerCrashLogger2";
        int argc = 1;
        char * argv = &name[0];
        QApplication a(argc,&argv);

        ISchedule::ptr schedule(new DummyScheduler);
        Bedroom::ptr bedroom(new Bedroom);
        Workers::ptr workers(new Workers(IWorkerFactory::ptr(new QtEventWorkerFactory(schedule, bedroom))));

        {
            TRACE_PERF("Catch info from a crashed worker as it happens");

            WorkerCrashLogger wcl(workers);

            // Catch info from a crashed worker as it happens
            addAndWaitForStop(workers);
            addAndWaitForStop(workers);
        }

        Workers::DeadEngines de = workers.write ()->clean_dead_workers();
        EXCEPTION_ASSERT_EQUALS(de.size (), 0u);
    }

    {
        DEBUG TaskInfo ti("Support not consuming workers");

        std::string name = "WorkerCrashLogger3";
        int argc = 1;
        char * argv = &name[0];
        QApplication a(argc,&argv);

        ISchedule::ptr schedule(new DummyScheduler);
        Bedroom::ptr bedroom(new Bedroom);
        Workers::ptr workers(new Workers(IWorkerFactory::ptr(new QtEventWorkerFactory(schedule, bedroom))));

        // Catch info from a previously crashed worker
        addAndWaitForStop(workers);

        {
            TRACE_PERF("Support not consuming workers");

            WorkerCrashLogger wcl(workers, false);

            a.processEvents ();

            // Catch info from a crashed worker as it happens
            addAndWaitForStop(workers);
        }

        // Should not have consumed any workers
        Workers::DeadEngines de = workers.write ()->clean_dead_workers();
        EXCEPTION_ASSERT_EQUALS(de.size (), 2u);
    }
}
Пример #4
0
// In Windows, wmain() is an alternate entry point for main(), and receives the same parameters
// as main() but encoded in Windows Unicode (UTF-16); "wide" 16-bit wchar_t characters.  The
// WindowsCommandLine object converts these wide character strings to a UTF-8 coded equivalent
// and makes them available through the argv() and envp() members.  This enables bridgeMain()
// to process UTF-8 encoded arguments and environment variables without regard to platform.
int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
    mongo::WindowsCommandLine wcl(argc, argvW, envpW);
    int exitCode = mongo::bridgeMain(argc, wcl.argv(), wcl.envp());
    mongo::quickExit(exitCode);
}