Peace
You're right (If I read correct)
I am right if I wrote right.
Peace
that means it is good practice to use flush ? right? 🤔
clearing buffer free the storage, I think.
Prince Of Persia
Buffer is static array
Prince Of Persia
So size of empty or full are the same in real projects
Igor🇺🇦
that means it is good practice to use flush ? right? 🤔
It's a bad practice to use flush for no reason. There is a reason why cout has a buffer. Flushing means it needs to do a system call and print. That's slow. You want to do it as little as possible.
Peace
A buffer flush is the transfer of computer data from a temporary storage area to the computer’s permanent memory. For instance, if we make any changes in a file, the changes we see on one computer screen are stored temporarily in a buffer. Usually, a temporary file comes into existence when we open any word document and is automatically destroyed when we close our main file. Thus when we save our work, the changes that we’ve made to our document since the last time we saved it are flushed from the buffer to permanent storage on the hard disk.
Anonymous
I need help in C++ Language because I am fresher programmer .Please give some suggestion for me
Peace
I need help in C++ Language because I am fresher programmer .Please give some suggestion for me
go for geeksforgeeks and cppreference.com website for topics and clarification.
MᏫᎻᎯᎷᎷᎬᎠ
.
React
Is there any one who is expert in solving c language questions??? Please dm me 🙏🙏
React
Actually I need help in c questions
Anonymous
Just ask
React
Can I send u the ques ??
Anonymous
Send here the question, what you have tried and what's not working
Krishnaa
How can we take specific formatted input in c++?
Peace
how to define a variable length array without Dynamic memory allocation in C++ ?
Dark
Can anyone tell from where to install mingw
artemetra 🇺🇦
Can anyone tell from where to install mingw
look up msys2 mingw in google and you'll find it
Amu
The supplier generator thread. The argument is a pointer to * the shared Simulation object.
Amu
supplierGenerator(void* arg) {. } How do i make this arg point directly and be able to manipulate a class called Simulation in c++?
Amu
Anyone?
Anonymous
Pass a pointer to the class if I understood ur question
Amu
What's the problem?
i tried doing Simulation* sim = reinterpret_cast<Simulation*>(arg); but i get segfault repeatedly
Amu
what do you mean by bad pointer?
Anonymous
Or something beyond that which u r doin wrong
Amu
oh i see
Anonymous
what do you mean by bad pointer?
You don't point to the object
Amu
i also tried Simulation* sim = (Simulation*)(arg);
Anonymous
What?
Amu
because simulation is explicitly constructed
Amu
class Simulation { public: TaskQueue supplierTasks; TaskQueue customerTasks; EStore store; int maxTasks; int numSuppliers; int numCustomers; explicit Simulation(bool useFineMode) : store(useFineMode) { } };
Anonymous
Where is the object?
Anonymous
And where do u pass it
Anonymous
this
Not what I asked u
Amu
in my function called suppliergenerator
Anonymous
I didn't ask where is the definition of the object.
Anonymous
in my function called suppliergenerator
What? Isn't it the one with the void pointer?
Amu
yes it is
Anonymous
Wtf? Lol. I'm asking where do u create the object.
Amu
Wtf? Lol. I'm asking where do u create the object.
as i said i create the object in the void function called suppliergenerator, isn’t that what you meant?
Anonymous
as i said i create the object in the void function called suppliergenerator, isn’t that what you meant?
Nope. It's not created there. You want to pass a pointer of the object to that function, no?
Amu
Nope. It's not created there. You want to pass a pointer of the object to that function, no?
Yes i want the arg pointer in my function i.e suppliergenerator(*arg) to point to the simulation object
Amu
Nope. It's not created there. You want to pass a pointer of the object to that function, no?
the simulation object is created in a file called requestGenerator.cpp which creates and enqueues information into a taskQueue
Amu
“ Use a SupplierRequestGenerator to generate and enqueue * requests.”
Amu
enqueueTasks(int maxTasks, EStore* store) { taskCount = 0; while (taskCount < maxTasks || maxTasks < 0) { taskQueue->enqueue(generateTask(store)); printf("%s", "enquing occurs"); taskCount++; sthread_sleep(0, 100000000); } }
Amu
the store and max taskargument in requestGenerator.cpp are from the Simulation object
Amu
and theres another file called taskqueue as well
Anonymous
I don't see where u pass it here to supplierGenerator
Anonymous
I don't even see the object creation here.
Amu
SupplierRequestGenerator:: SupplierRequestGenerator(TaskQueue* queue) : RequestGenerator(queue) { } Task SupplierRequestGenerator:: generateTask(EStore* store) { …… }
Amu
the generate task has so many different things that the supplier should do (hence the …)
Amu
SupplierRequestGenerator mySupplier(&sim->supplierTasks);
Amu
this is how we pass it if the object was called sim in the first file
Anonymous
supplierTasks is a Simulation object?
Amu
yes
Amu
it is a queue defined in another file
Anonymous
Explain
Amu
I have a file called taskqueue which is supposed to concurrently handle customer request and supplier requests. This task queue is in the simulation object as taskqueue supplier task and task quque custoemr tasks
Anonymous
So under sim there is a Simulation object called supplierTasks?
Amu
exactly
Anonymous
Show it
Anonymous
Where do you define "Simulation* supplierTasks"
Anonymous
Or "Simuation supplierTasks"
Amu
Where do you define "Simulation* supplierTasks"
you already saw it in the simulation object
Anonymous
No
Anonymous
U said it was the Simulation Object