Skip to content

Instantly share code, notes, and snippets.

@Rapptz
Forked from rightfold/gist:9152ad29eefbba087c9c
Created September 17, 2014 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rapptz/fb74c1c0bb61084347c6 to your computer and use it in GitHub Desktop.
Save Rapptz/fb74c1c0bb61084347c6 to your computer and use it in GitHub Desktop.
#pragma once
#include <boost/asio.hpp>
#include <sol.hpp>
namespace asio_sol {
void install_io_service(sol::state& lua) {
// ways to construct go here through sol::types<...> groups
sol::constructors<sol::types<>> ctor;
sol::userdata<boost::asio::io_service> io_service(
"io_service", ctor,
"run", [] (boost::asio::io_service& s) { s.run(); }
);
auto asio = lua.get<sol::table>("asio");
asio.set_userdata(io_service);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment