c++ thread, async 예시
//C++
#include <iostream>
#include <future>
// 쓰레드 사용시, client list 벡터
std::vector<std::thread*> clientlist;
wsa wsa;
// 쓰레드 버전
clientlist.push_back(new std::thread(&wsa::client, wsa, sock_connected, clientAddr, &clientlist));
// Async 사용시, client list 벡터
a_clientlist.push_back(std::async(std::launch::async, &wsa::client, wsa, sock_connected, clientAddr, &clientlist));
c++ thread, async 비교
// c++ async
std::future<void> a = std::async(std::launch::async, for_print, 'a');
std::future<void> b = std::async(std::launch::deferred, for_print, 'b');
b.get();
std::future<void> c = std::async(for_print, 'c');
wsa temp;
// c++ thread
new std::thread(&wsa::Recv_, temp, clientSock);
// c++ async
std::future<wchar_t*> a = std::async(std::launch::async, &wsa::Recv_, temp, clientSock);
C# Parallel
// 단순 병렬 분할 크기 전송
Parallel.For (0, cnt, i =>
{
int start_index = i * 분할크기
socket.Send(file_byte, start_index, 분할크기, SocketFlags.None);
});