File indexing completed on 2024-04-06 12:13:08
0001 #include "FWCore/SharedMemory/interface/ControllerChannel.h"
0002 #include "FWCore/SharedMemory/interface/WorkerChannel.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004
0005 #include <memory>
0006 #include <string>
0007 #include <stdio.h>
0008 #include <cassert>
0009 #include <thread>
0010
0011 #include "controller.h"
0012 #include "worker.h"
0013 namespace {
0014
0015 const char* jobType(bool isWorker) {
0016 if (isWorker) {
0017 return "Worker";
0018 }
0019 return "Controller";
0020 }
0021 }
0022
0023 int main(int argc, char** argv) {
0024 bool isWorker = true;
0025 int retValue = 0;
0026 try {
0027 if (argc > 1) {
0028 retValue = worker(argc, argv, WorkerType::kOKTimeout);
0029 } else {
0030 isWorker = false;
0031 retValue = controller(argc, argv, 5);
0032 }
0033 } catch (std::exception const& iException) {
0034 std::cerr << "Caught exception\n" << iException.what() << "\n";
0035 if (isWorker) {
0036 std::cerr << "in worker\n";
0037 } else {
0038 std::cerr << "in controller\n";
0039 }
0040 return 1;
0041 }
0042 if (0 == retValue) {
0043 std::cout << jobType(isWorker) << " success" << std::endl;
0044 } else {
0045 std::cout << jobType(isWorker) << " failed" << std::endl;
0046 }
0047 return 0;
0048 }