B;
Does the end of string contain null?
B;
https://pastebin.com/9t5B0cW1
B;
I am printing this vector string using iterator. In order to print correct values from the string I need to put -1 at the start and end of the iterator. Otherwise it prints garbage value. Any idea why
moyo
its kinda of overwhelming so you better just use the terminal
Alright but direct me to some resources or tell me a way around it.
andriiko489
Hi! My program has two options: keyboard i/o and file i/o. Sometimes, when I use the file input option, the program crashes with the error message 'heap corruption detected after normal block.' What can I do to fix this issue pastebin: https://pastebin.com/gz9vT08W input.txt: Перше речення хороше Друге ні Третє речення краще за друге Четверте речення нормальне
Ya deway
hello all, i'm using multi threading to speed up my program which works with http requests, i would like to improve the normal multi threading (which works with a simple queue) like this: I put 5 threads in the queue and instead of waiting for all of them to complete and loading another 5, I would like that when a thread in the queue completes before the others it is replaced with a new one. It would be possible? do you have any advice?
Anonymous
Is it possible to create an API using c++ ?
search "reo7sp" on github
Ya deway
Look up terms like thread pool, executor service and so on in Google
I would like to modify the functioning of the pool adapting it to my specific function. I don't think there is anything ready made on the internet
Anonymous
I would like to modify the functioning of the pool adapting it to my specific function. I don't think there is anything ready made on the internet
What do you mean by specific function? You want the threads in the pool to execute your specific functionality? If so, there are multiple implementations out there which do that.
Ya deway
I guess the only problem is to develop a function that recognizes when one of the 5 threads is finished and then replace it with a new one. I'm concerned about the sync. I still have to inform myself better
Anonymous
I guess the only problem is to develop a function that recognizes when one of the 5 threads is finished and then replace it with a new one. I'm concerned about the sync. I still have to inform myself better
Why do you want to replace a thread with a new one? Why can't the old thread take on a new task once it is finished with the old task? That is the whole point of a thread pool. Creating a thread is an expensive operation (albeit simpler than creating a process). Why do you want to do this?
Ya deway
Why do you want to replace a thread with a new one? Why can't the old thread take on a new task once it is finished with the old task? That is the whole point of a thread pool. Creating a thread is an expensive operation (albeit simpler than creating a process). Why do you want to do this?
Because the code in this way will be much faster. The https sites have responses that vary from each other and often time out. Instead of waiting for all 5 processes to be completed I prefer to use more system resources to speed up the running of the script. This replacing the completed threads with new ones
Anonymous
Because the code in this way will be much faster. The https sites have responses that vary from each other and often time out. Instead of waiting for all 5 processes to be completed I prefer to use more system resources to speed up the running of the script. This replacing the completed threads with new ones
If the thread has completed it doesn't make sense to replace it with a new thread. Once a thread completes it's task, it can just take on a new task. How does it matter if the new task is being handled by a thread that was created already or by a new thread?
Ya deway
If the thread has completed it doesn't make sense to replace it with a new thread. Once a thread completes it's task, it can just take on a new task. How does it matter if the new task is being handled by a thread that was created already or by a new thread?
I use more than one thread at the same time. I have a thread list long for example 5 threads. using normal threading this queue is only updated when all 5 threads are completed. This implies that I have to wait for all threads to complete and then in the case of a timeout of only one thread, all the others are affected. The code would be significantly faster if I replaced the finished threads with new threads which obviously process different data than the previous ones
Anonymous
I use more than one thread at the same time. I have a thread list long for example 5 threads. using normal threading this queue is only updated when all 5 threads are completed. This implies that I have to wait for all threads to complete and then in the case of a timeout of only one thread, all the others are affected. The code would be significantly faster if I replaced the finished threads with new threads which obviously process different data than the previous ones
I don't even understand what you are saying. If there are 5 threads, they can handle 5 tasks concurrently. When one thread finishes earlier, it can take on a new task from some work queue. If a thread task times out, you can react to it by letting it take on a new task from the work queue. Infact you can go a step ahead and implement work stealing as well which is a slightly more advanced concept. I have this strange feeling that you are trying to do things without even understanding the solution. Please read up a good book on concurrency before attempting to optimize concurrent code.
Ya deway
But other factors come into play such as the handling of already resolved arguments, how do I tell the thread which input to take?
Anonymous
So would it be possible to launch the 5 threads without a queue and when one thread finishes one task it creates another with different argument? In this case the task would be a function to be called with variable arguments
Yes. There are things likepackaged_task, promise and future that can be used to handle tasks with different arguments. There is a lot in C++ outside of std::thread and std::async. Like I said, read a good book.
Ya deway
I'll look into it, thanks anyway
Anonymous
But other factors come into play such as the handling of already resolved arguments, how do I tell the thread which input to take?
Most thread pool implementation s usually have a work queue. Any new task is pushed into this work queue. A thread from the pool takes up a task from this queue when it has completed its task. In your case your task logic also needs to account for the fact that a timeout can occur and consider it as akin to having completed its task.
Ya deway
Most thread pool implementation s usually have a work queue. Any new task is pushed into this work queue. A thread from the pool takes up a task from this queue when it has completed its task. In your case your task logic also needs to account for the fact that a timeout can occur and consider it as akin to having completed its task.
Indeed it didn't make sense how I interpreted it, maybe because I'm used to python🤣. In my problem I used a TXT list from which I took the data to be analyzed one by one and loaded the first 5 for each thread created(5), and consequently the list counter increased by 5. This way is inconvenient in fact so I have thought of dividing the list according to the thread number (5 in this case) and assigning that portion to each thread. This way I shouldn't have any kind of problem, once the thread completes the first string to parse, instead of terminating, it continues with the second one until the end of its portion. If it encounters a timeout obviously the other threads are not affected! Thing is, in all of this I wanted to operate on a single list instead of dividing it by number of threads, how stupid
Mercure Tashkent Hotel
guys plz share with free courses for C++ for beginners. except CS50 🙏
Maverick
Is using function save us from getting TLE error?
Maverick
aitor
Please reply as fast as possible.....
It's not our problem that you're in your job...Ask your coworkers
klimi
Yes
I don't think there is any such error like that. What are you trying to do?
klimi
These are common in algorithmic coding problems.
so what does it have to do with c/c++ programming?
Apk
Yes it should probably not be asked in this group, unless they explain more on what they need.
Maverick
I don't think there is any such error like that. What are you trying to do?
In Online judges they consider time limit exceeded error before accepting the solution
Maverick
I solved the problem in a same way... In first attempt it was a direct code And in second one I transfered the whole working of code in a function . Second one was accepted!.
Maverick
I don't think there is any such error like that. What are you trying to do?
Sorry, I thought algorithm is also a part of programming so I just asked it out.
klimi
In Online judges they consider time limit exceeded error before accepting the solution
oh, so they make a new restraint, you haven't told so; if it is just time restraint, then making function in most cases won't help you with speed, it will do actually the opposite since you need to call the function. Compilers try to optimize this by inlining the functions so you won't actually see huge performance hit.
klimi
Sorry, I thought algorithm is also a part of programming so I just asked it out.
It's fine if you actually explain the problem, there is not runtime error like TLE in just c/c++; if this is external thing, you need to say so
Pavel
How experienced you are? You can make a chat backend (and either a console or GUI app for it if feeling you want GUI). Should make you busy for a while :D
P
please check this code: ```cpp
Chat Boss
P sent a code, it has been re-uploaded as a file
P
the code is for this question
P
https://atcoder.jp/contests/abc296/tasks/abc296_a
P
why its not working?
P
please coding community help me to debug this code
B;
Where is the question?
P
Where is the question?
https://atcoder.jp/contests/abc296/tasks/abc296_a
P
this is the question
B;
its working fine, i see no need for debugging
P
its working fine, i see no need for debugging
but the code is not showing output
B;
although your logic may be flawed, you have to work on that
P
wait giving screenshot
Danya🔥
P
the group does not allow screenshot
P
🥲
B;
you can send me in personal chat
P
What’s up with this code ?
i uderstood... there was a problem in the code for that reson it was not working
P
the problem was i was taking string s in a forloop
B;
Do you mind sharing the correct code?
MaaKa
the problem was i was taking string s in a forloop
Okay And the else count<<“yes”; I thought that was supposed to be an else statement But you placed it at the end of the program Did it work well still ?
P
Do you mind sharing the correct code?
yes i mind because you misled me .... and after that you changed the username
B;
You don't need lie bro we are all learners. Its okay if you can't do
B;
😂
💀👍
MaaKa
yea brother
Okay nice
P
how to rise warning?
MaaKa
Mention admin or use rose command Starts with a forward slash /
P
Okay nice
no i was not jocking brother....i was not able to share the screenshot here else i could show you. what he tokd me
P
how to do that? its not working
MaaKa
no i was not jocking brother....i was not able to share the screenshot here else i could show you. what he tokd me
Maybe he was only trying to help in he’s own way. As learners not everyone helping know what they’re saying