| | |
| | | * |
| | | * ===================================================================================== |
| | | */ |
| | | #include "app_arg.h" |
| | | #include "box.h" |
| | | #include "center.h" |
| | | #include "defs.h" |
| | | #include "signalhandle.h" |
| | | #include <chrono> |
| | | #include <thread> |
| | | 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}); |
| | | // BHomeShm().Remove(); // remove ? |
| | | run = false; |
| | | t.join(); |
| | | return 0; |
| | | } |
| | | |