Lounge<C++>

Today we're daydreaming about C++26 reflection
Nov 7, 2020 16:35
it says async cannot have an atomic parameter
Nov 7, 2020 16:35
the compiler doesn't accept that somehow
Nov 7, 2020 16:09
I would need to use a mutex
Nov 7, 2020 15:40
if you need to exit a thread that's the only way
Nov 7, 2020 15:36
std::string apiCall(std::string url, std::string data, std::atomic<bool> run);
Nov 7, 2020 15:34
nop
Nov 7, 2020 15:32
however somehow it doesn't accept an atomic parameter
Nov 7, 2020 15:32
std::async is a good abstraction for threads
Nov 7, 2020 15:31
it returns a future
Nov 7, 2020 15:30
in prayers we ask for forgiveness, praise our fait and forecast future knowledge. That's exactly what my question is all about. After all, we're talking about C++ futures
Nov 7, 2020 15:28
std::async(std::launch::async, apiCall, param1, param2, run); where run is the atomic bool
Nov 7, 2020 15:28
how to pass an atomic<bool> var to an async thread?
Nov 7, 2020 15:28
now going to the actual prayer
Nov 7, 2020 15:27
the other room is just for the Élite
Nov 7, 2020 15:27
that's great
Nov 7, 2020 15:26
is this the place to cry about C++ multithread programming?
Nov 7, 2020 15:25
Hi
 

C++ Questions and Answers

Solve problems and approach solutions. Just ask and lurkers wi...
Nov 1, 2020 17:06
ok so back to C-style and err return values
Nov 1, 2020 17:05
let's say I'm reading USD-EUR conversion value from an API and I receive a http status 500 - server error. Should I raise an exception and somehow catch it in the main thread? Or return an impossible value -1
Nov 1, 2020 17:04
prayers are the backbone of programming
Nov 1, 2020 17:03
raising exceptions or using return values as error indicators?
Nov 1, 2020 17:03
what is the standard way to deal with errors in threads?
Nov 1, 2020 17:02
hi
Oct 29, 2020 09:12
it doesn't make much sense to use threads in this way
Oct 29, 2020 09:12
which blocks the draw thread
Oct 29, 2020 09:10
then handle.get() halts execution?
Oct 29, 2020 09:09
auto handle = std::async(std::launch::async, parallel_sum, mid, end);
Oct 29, 2020 09:06
the API function returns a string, I can then check if the string is null in the draw thread (API request still running) or if not empty
Oct 29, 2020 09:05
std::async() should do the work right?
Oct 29, 2020 09:05
it's been a while since I have played with threads in c++
Oct 29, 2020 09:04
do you mean using a separate thread?
Oct 29, 2020 09:03
Let's say I need to invoke an API and show the result, I'd create a window using ImGui::Begin and ImGui::End, in between call the API and show the result using ImGui::Text()
Oct 29, 2020 09:01
what if I have to perform an action that takes some seconds? The GUI freezes
Oct 29, 2020 09:00
which means code within the main draw loop should be fast to execute
Oct 29, 2020 09:00
from what I understand it's a real-time draw cycle
Oct 29, 2020 08:59
have you ever used Dear ImGui?
Oct 29, 2020 08:59
I see
Oct 29, 2020 08:56
which means I'd have to write a makefile for the app
Oct 29, 2020 08:55
VSCode uses makefiles
Oct 29, 2020 08:55
ok
Oct 29, 2020 08:51
I am using dear imgui so it's not nice that when I open the executable a terminal window appears
Oct 29, 2020 08:51
I see the only alternative is "command line"
Oct 29, 2020 08:49
Hi, anyone uses Xcode for C++ here?
Oct 28, 2020 18:59
I successfully converted the string into a std::time_t var
Oct 28, 2020 18:53
then somehow convert the time string and compare with "millis"
Oct 28, 2020 18:52
const auto now = std::chrono::system_clock::now();
const auto twoWeeks = std::chrono::hours(24 * 14);
const auto lastTwoWeeks = now - twoWeeks;
const auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(lastTwoWeeks.time_since_epoch()).count();
Oct 28, 2020 18:52
This is what I was doing
Oct 28, 2020 18:52
I need to check if two weeks have passed
Oct 28, 2020 18:51
I have a string containing a timestamp, say "2020-October-18 23:12:34"
Oct 28, 2020 18:51
do you know how to deal with time in c++?