Deepak
*topic
lethal Robert
//Thank you @MissRose_bot
𝙡𝙚𝙗𝙚𝙣𝙨𝙡𝙖𝙣𝙜𝙚𝙧𝙨𝙘𝙝𝙞𝙘𝙠𝙨𝙖𝙡𝙨𝙨𝙘𝙝𝙖𝙩𝙯
/get cppbookguide
ㅤ
if i have a dynamic array of classes, what's the best way to add a new class to that array?
ㅤ
I am not very good at c++ yet, now i have sth like this:
Class *sth = new Class[10] and i want to get the size to 11
Pavel
Alisher
You need to reallocate the memory for size 11
ㅤ
Seems like i have no other choice that to go and learn what exactly is std::vector
Anonymous
Pavel
some ppl on github said it is bad using realloc for classes in c++, i dont want to test it XD
That's true, for a generic case you would need to allocate a new array and move every object there. Then to avoid extra constructor call, you would probably need to allocate raw memory instead of using arrays and manually construct and destruct objects there. Then to fight with the extra cost of allocations and movement, you would want to preallocate some memory in advance and store two sizes: allocated and used.
Well, or use std::vector that does all that stuff for you :)
Anonymous
i hate signal races
Anonymous
Guys how can i get a free usa number help
Yazan
Hello
Yazan
Guys
I have c++ exam
Please someone help so urgent
Diego
Lmao we ain't going to solve your exam for you
Diego
If you've got any more specific questions, and some of us have free time, we may consider answering
Devjit
Hello everyone
Tecatito
Hello
zenn
Guys i have ( programming skill) mock exam today.please Can u guys help me ? B'coz i am new student
Ammar
Do your exam yourself.
zenn
Seriously? . I have no knowledge about programming . So i applied pvt campus .
zenn
Thats why i want to pass and I'm trying to do that course
zenn
I don't want to argue . If there is anyone who can help me. Please
-Arya!
I need someone to make a soft ,
If you have free time dm so I can explain what I exactly need ....
'''''''
zenn
'''''''
Thnx
zenn
*Sri Lanka
Anonymous
i hate signal races
Signal races? Do you mean a race condition on a global structure because of an asynchronous signal handler?
'''''''
/report
Talula
Fact but not the group for it.
Anonymous
Anonymous
https://gist.github.com/Total-Control-9985/7dafc08de8231a544c8c19853cb19c4f
Anonymous
Talula
Anonymous
ok, it is an issue with my join thread...
Anonymous
ok i have another race i need to figure out
Anonymous
by the time i send the SIGCONT
and i wait for my process to change state to CONTINUE
it may already have continued and exited before waitpid is called
Anonymous
Anonymous
Anonymous
CASE STOPPED
CONTINUE THREAD: 265096
EXITING
waiting for CONTINUE pid 265096
WAIT TERMINATED
CASE DEFAULT
WAIT CASE TERMINATED
JOINED
Anonymous
Anonymous
which, if fast enough, this can happen
CONTINUE THREAD: 265485
EXITING
waiting for CONTINUE pid 265485
WAIT TERMINATED
JOINED
Talula
Anonymous
and i got another bug
wait_for_state (pid 266027): unknown wait while waiting for state: CONTINUE
Talula
A proportional–integral–derivative controller (PID controller or three-term controller) is a control loop mechanism employing feedback that is widely used in industrial control systems and a variety of other applications requiring continuously modulated control. A PID controller continuously calculates an error value.
Anonymous
Anonymous
Anonymous
and i think the cause is this
LOG_INFO("CONTINUE THREAD: %d", thread->pid.load());
thread->status = Thread::StatusList::RUNNING;
sendSignal(thread, SIGCONT);
if (getpid() != thread->pid) {
LOG_INFO("WAITING FOR CONTINUE THREAD: %d", thread->pid.load());
waitForContinue(thread);
LOG_INFO("WAITED FOR CONTINUE THREAD: %d", thread->pid.load());
}
CONTINUE THREAD: 267012
boo!
STOP THREAD: 267012
WAITING FOR CONTINUE THREAD: 267012
wait_for_state (pid 267011): unknown wait while waiting for state: CONTINUE
'''''''
Anonymous
which is another signal race
Anonymous
bloody signal races :(
Anonymous
but now i have a problem, waitForContinue(Thread * thread) CANNOT be used to wait for a STOP
since it is meant to send SIGCONT to the program and then wait for the program to be delivered SIGCONT
Anonymous
as the program MAY do this:
Prog1: kill(pid, SIGCONT);
SCHED SWITCH
Prog2 RECV SIGCONT
Prog2: kill(self, SIGSTOP);
Prog2 RECV SIGSTOP
SCHED SWITCH
Prog1: waitpid(pid, &status, WCONTINUED|WSTOPPED); /* check status for continue or termination */
klimi
Pavel
Anonymous
Anonymous
eg https://gist.github.com/Total-Control-9985/94919d165d43f908560fdbb3f795715e
Carlos
Carlos
Anonymous
would i need to do this? https://gist.github.com/66bf4cd559b1b4b36261bc68cbc838d0
Anonymous
welp that helps but it is still not enough
Anonymous
STOP THREAD AND WAIT FOR CONTINUE: 272642
CONTINUE THREAD: 272642
boo!
STOP THREAD AND WAIT FOR CONTINUE: 272642
wait_for_state (pid 272641): unknown wait while waiting for state: CONTINUE
Anonymous
think it is cus of this
LOG_INFO("CONTINUE THREAD: %d", thread_pid);
thread->status = Thread::StatusList::RUNNING;
sendSignal(thread_pid, thread, SIGCONT);
waitForContinue(thread);
// we are sending a signal to ourself, so we must exist, no need to check for error
kill(pid, SIGSTOP);
// self cannot wait for SIGCONT since we are already in a continued state when kill returns
while (thread->status != Thread::StatusList::RUNNING);
Hamza
Anonymous
Anyone
search the Internet.
Anonymous
#cbook
Hamza
Pankaj
/report
Anonymous
made a little script that continuously executes a command until output is matched and then outputs the entire output of that command
if [[ $# < 2 ]]
then
echo "usage: $(basename $0) \"output to match against\" command <optional args>"
fi
string="$1"
shift 1
cmd="$@"
while true
do
rm UNTILLOUTPUTMATCHESEOF.txt > /dev/null 2>&1
script --flush --quiet --command "$cmd" UNTILLOUTPUTMATCHESEOF.txt # cmd might hang
grep -q "$string" UNTILLOUTPUTMATCHESEOF.txt
if [[ $? == 0 ]]
then
cat UNTILLOUTPUTMATCHESEOF.txt
rm UNTILLOUTPUTMATCHESEOF.txt
exit
fi
done
Anonymous
cus i dont wanna keep pressing
up
enter
on my keyboard to try to find any bugs
Юрій
Can someone explain what`s wrong
Юрій
thread th1(LorisThread, s, socket_address);
Юрій
void LorisThread(SOCKET s, sockaddr_in* socket_address) {
Anonymous
use a paste site