'2016/08'에 해당되는 글 2건

  1. 2016.08.24 TIME_WAIT 커널단에서 해결법 3
  2. 2016.08.24 ios task worker


tcp_fin_timeout


# echo 10 > /proc/sys/net/ipv4/tcp_fin_timeout

 

# vi /etc/sysctl.conf

#tcp fin timeout setting

net.ipv4.tcp_fin_timeout=10



tcp_tw_recycle 


# echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle

# vi /etc/sysctl.conf

#tcp tw_recycle setting

net.ipv4.tcp_tw_recycle=1



tcp_tw_reuse


# echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse

# vi /etc/sysctl.conf

#tcp_tw_reuse setting

net.ipv4.tcp_tw_reuse=1

Posted by 명혀니
,

ios task worker

Programming Skill 2016. 8. 24. 12:45
#include <iostream>
#include <future>
#include <type_traits>
#include <boost/asio.hpp>
 
using namespace boost::asio;
 
io_service ios;
io_service::work work{ ios };
 
template < typename Func >
auto post(Func&& func)
{
  using return_type = decltype(func());
  
  auto promise = std::make_shared<std::promise<return_type>>();
  auto future = promise->get_future();
 
  ios.post
    (
      [promise, func]
      {
        promise->set_value(func());
      }
    );
 
  return future;
}
 
 
int main()
{
  auto async_res = std::async
    (
      std::launch::async, 
      [] 
      {
        ios.run();
      }
    );
 
  int a = 10;
  int b = 20;
 
  auto future = post([a, b] { return a*b; });
 
  std::cout << future.get() << std::endl;
 
  return 0;
}



출처 : http://zepeh.tistory.com/315


Posted by 명혀니
,