Support Board
Date/Time: Wed, 27 Nov 2024 16:38:40 +0000
Post From: C++ threads inside a ACSIL study?
[2023-02-08 22:03:36] |
User133994 - Posts: 80 |
Now, I have the "breaking" lines of code identified. No clue as to why? Please assist. s11n_example::client* pClient = reinterpret_cast<s11n_example::client*>(sc.GetPersistentPointer(pClientKeys[0])); if (pClient == nullptr){ try { boost::asio::io_service io_service; boost::asio::io_service::work work(io_service); sc.SetPersistentPointer(pClientKeys[0], new s11n_example::client(io_service, "127.0.0.1", std::to_string(12344), sc)); // 3 ways to attempt some threading approaches--all 3 compile, but SC crashes when I press "Add Custom Study" button //NONE of these "thread" approaches work. They are all NON-BLOCKING--which is what I need. However, there is always a SC crash as soon as I click "Add Custom Study" button! //1st attempt>> std::thread run_thread([&]{ io_service.run(); }); << CRASH //2nd attempt>> boost::thread run_thread(boost::bind(&boost::asio::io_service::run, boost::ref(io_service))); << CRASH //3rd attempt>> boost::thread run_thread([&] { io_service.run(); }); <<CRASH io_service.run(); //<<<------ BLOCKING, but works!! (i.e. I see data from the "other chart" in messages) the study is added to the chart with no issues, however, program flow (of the study) is halted at this line...thus, no updates are possible; i.e. I need to call pClient.RequestData() on each new bar..after this line.. Reminder: the server + client works as expected with threads in separate main() programs; it is just the integration into the scsf_ custom ACSIL study that is causing the issue--specifically with the client now. Date Time Of Last Edit: 2023-02-08 22:06:10
|