olli
Thread pool can solve this But As far as I understand async came to solve the high costs of threads(like system resources as Rust books explanation of Asynchrounounce mentioned that explicitly) So that means async doesn't use threads in its internal implementation
Yes, it can. But in practice the overhead is extremely high. You need to protect the access to data structures to prevent race conditions, your operating system needs to context switch between the different threads and so on.. additionally for a network stack you spent a lot of time waiting anyway asynchronous functions can but do not need to run on a different thread.
MᏫᎻᎯᎷᎷᎬᎠ
without blocking means a different threads and async doesn't use threads this is soo confusing
Alex
As far as I know Asynchronous means running on different context concurrently without blocking each other
there are synchronous and asynchronous IO. sync: make request and get data. async: set handler for getting data, handler is called if data ready
Alex
async is not about threads, coroutine etc.
MᏫᎻᎯᎷᎷᎬᎠ
How does it wait, if it's not by using threads so that it doesn't block the caller and notifies it when it's ready
MᏫᎻᎯᎷᎷᎬᎠ
are you saying that it's a platform specific implementation or it's just a troll?😂
MᏫᎻᎯᎷᎷᎬᎠ
Like one above just mentioned Windows Api
Alex
are you saying that it's a platform specific implementation or it's just a troll?😂
I am just trying to say you mess ortogonal entities like: async/sync IO with threads, coroutines etc
MᏫᎻᎯᎷᎷᎬᎠ
Alex
async looks like: main() { socket s = get_socket(); SetReadHandler(s, READ_IO, read_func); do_other_stuff().. } read_func() { //read data here }
Alex
for example nodejs does not have threads, but it has async nature
Alex
like this one: var req = http.request(getOptions(i), function(res) { res.on('data', function (body) { parseLocation(body); }); });
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Node uses threads under the hood
https://medium.com/better-programming/is-node-js-really-single-threaded-7ea59bcc8d64
Alex
you don`t get your request immediately, you provide callback to be called
Alex
Node uses threads under the hood
but it is still not good idea to compare async IO with corotune, goroutine, threads, process and so on
Alex
you can compare async IO with sync IO
Alex
what is better for you
Alex
this is like comparing parallel algorithm with threads
MᏫᎻᎯᎷᎷᎬᎠ
this is like comparing parallel algorithm with threads
I'm not having a debate here or something to prove my points this is called confusion
MᏫᎻᎯᎷᎷᎬᎠ
and luckily someone wants to resolve it
Nils
How do I yield in asio?
kodes
Can we use struct instead of class for linked list in c++??
Alex
yes
Anonymous
Wojak
What is making this code timeout ?😥 #include <bits/stdc++.h> using namespace std; vector<string> split_string(string); // Complete the squares function below. int squares(int a, int b) { int counter=0; for(int i=a;i<=b;i++) { float k=sqrt(i); if(k-floor(k)==0) counter++; } return counter; } int main() { ofstream fout(getenv("OUTPUT_PATH")); int q; cin >> q; cin.ignore(numeric_limits<streamsize>::max(), '\n'); for (int q_itr = 0; q_itr < q; q_itr++) { string ab_temp; getline(cin, ab_temp); vector<string> ab = split_string(ab_temp); int a = stoi(ab[0]); int b = stoi(ab[1]); int result = squares(a, b); fout << result << "\n"; } fout.close(); return 0; } vector<string> split_string(string input_string) { string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { return x == y and x == ' '; }); input_string.erase(new_end, input_string.end()); while (input_string[input_string.length() - 1] == ' ') { input_string.pop_back(); } vector<string> splits; char delimiter = ' '; size_t i = 0; size_t pos = input_string.find(delimiter); while (pos != string::npos) { splits.push_back(input_string.substr(i, pos - i)); i = pos + 1; pos = input_string.find(delimiter, i); } splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1)); return splits; }
Reham
hello i need help in an assignment i have been stuck on since the morning! it is about finding the smallest missing number
MK
Can we use struct instead of class for linked list in c++??
Use struct for only data oriented types and class for data and funtion oriented objects
Suryanand
hello i need help in an assignment i have been stuck on since the morning! it is about finding the smallest missing number
Segregate after sorting. Then write the utility code to find the relative missing number. Probably should work.
Gnostic Trades |
I want to start learning c++
Gnostic Trades |
I know basics of c
Gnostic Trades |
From where should I start learning c++ ?
Gnostic Trades |
Is it right decision to stop learning c and start learning c++, as I want to learn DS & algo and do competitive programming
Anonymous
You either learn C++ or competitive programming You do not have to learn C++ to do competitive programming
Suryanand
Is it right decision to stop learning c and start learning c++, as I want to learn DS & algo and do competitive programming
Well Learn C++ , if you wanna get into system dev n stuff . To start competitive programming any lang would do so choose your expertise wisely
Suryanand
Ds and algo is important in every aspect
Jenny
Hi
klimi
Hi
Yes hi
Jenny
Yes hi
How are you
klimi
#ot
su
Happy birthday to me. i'm a programmer
Asdew
Happy Day of the Programmer, even though I'm not sure if this place is appropriate for that as it seems that most people here can't program.
Gnostic Trades |
You either learn C++ or competitive programming You do not have to learn C++ to do competitive programming
Almost 70% competitive programmers using c++ for competitive programming
Anonymous
They do not use 99% of C++ capabilities
Gnostic Trades |
They are using lame C++
Will python also work?
Gnostic Trades |
Anonymous
MᏫᎻᎯᎷᎷᎬᎠ
They are using lame C++
It's better to make it as simple as possible Also bjarne advised so
MᏫᎻᎯᎷᎷᎬᎠ
Why would someone use template for such a simple stuff lol except fot show off of course
MᏫᎻᎯᎷᎷᎬᎠ
I didn't mean simple I meant lame
Like raw ptrs instead of smart ones
Anonymous
Anonymous
This kind of stuff
Anonymous
foo("abc"); Copies literal to src
Vlad
depends
Anonymous
If you will not save it without a copy of the whole string outside of a function, then yes
Reham
Segregate after sorting. Then write the utility code to find the relative missing number. Probably should work.
uhm yea the prob i had to do it without sorting and only with O(n) complexity,, but i figured it out thx for the suggestion :)
Prem
I am 🤚
V01D
Why?
Accel
hello i need help in an assignment i have been stuck on since the morning! it is about finding the smallest missing number
Bit manipulation?? It's sub type of missing number which is easily done by xor
Reham
Bit manipulation?? It's sub type of missing number which is easily done by xor
i tried xoring but am still new so it didn't work ,, i figured it out eventually thx tho :)
Renan
Question: Do programmers work on weekends? 🤔
Anonymous
Haven't you heard of 996ICU?
布丁
Some programmers in China work from 9am to 9pm 6 days a week
Anonymous
What is this?
Google it
布丁
https://996.icu/#/en_US