MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
without blocking
means a different threads
and async doesn't use threads
this is soo confusing
Alex
async is not about threads, coroutine etc.
MᏫᎻᎯᎷᎷᎬᎠ
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
Alex
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
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ᏫᎻᎯᎷᎷᎬᎠ
Alex
you don`t get your request immediately, you provide callback to be called
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ᏫᎻᎯᎷᎷᎬᎠ
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;
}
Anonymous
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;
}
Long code snippet, read pinned message
Reham
hello i need help in an assignment i have been stuck on since the morning!
it is about finding the smallest missing number
Suryanand
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
Anonymous
You either learn C++ or competitive programming
You do not have to learn C++ to do competitive programming
Suryanand
Ds and algo is important in every aspect
Jenny
Hi
klimi
Jenny
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.
Anonymous
Anonymous
Jesvi
Gnostic Trades |
Anonymous
Anonymous
They do not use 99% of C++ capabilities
Anonymous
Gnostic Trades |
Anonymous
MᏫᎻᎯᎷᎷᎬᎠ
Why would someone use template for such a simple stuff lol except fot show off of course
Anonymous
MᏫᎻᎯᎷᎷᎬᎠ
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
Suryanand
Prem
I am 🤚
V01D
Why?
Accel
Renan
Question:
Do programmers work on weekends? 🤔
Anonymous
Haven't you heard of 996ICU?
Renan
布丁
Some programmers in China work from 9am to 9pm 6 days a week
Anonymous
Renan
布丁
https://996.icu/#/en_US