/* * ===================================================================================== * * Filename: center_main.cc * * Description: * * Version: 1.0 * Created: 2021年04月13日 16时16分26秒 * Revision: none * Compiler: gcc * * Author: Li Chao (), lichao@aiotlink.com * Organization: * * ===================================================================================== */ #include "app_arg.h" #include "box.h" #include "center.h" #include "defs.h" #include "signalhandle.h" #include #include using namespace std::chrono_literals; int center_main(int argc, const char *argv[]) { AppArg args(argc, argv); if (args.Has("remove")) { BHomeShm().Remove(); return 0; } bool run = true; auto showStatus = [&]() { auto init = BHomeShm().get_free_memory(); uint64_t idx = 0; while (run) { std::this_thread::sleep_for(1s); printf("%8d shared memory: avail : %ld / %ld\n", ++idx, BHomeShm().get_free_memory(), init); } }; std::thread t(showStatus); BHCenter center(BHomeShm()); center.Start(); printf("center started ...\n"); WaitForSignals({SIGINT, SIGTERM}); run = false; t.join(); return 0; } namespace { static bool install = BoxInstall("bhshmq_center", center_main, "bhome center program."); }