Skip to content

Instantly share code, notes, and snippets.

@Zetaeta
Created October 30, 2012 10:16
Show Gist options
  • Save Zetaeta/3979454 to your computer and use it in GitHub Desktop.
Save Zetaeta/3979454 to your computer and use it in GitHub Desktop.
Preprocessed source of NetworkServer.cpp
namespace std
{
template < typename _Tp > struct integral_constant
{
static constexpr _Tp value = 0;
};
typedef integral_constant < bool > true_type;
template < typename ... >struct __and_;
template <> struct __and_ <>:true_type
{
};
template < typename _Tp, typename _Cp >
struct integral_constant <_Tp _Cp::*>:integral_constant < bool >
{
};
template < typename, typename > struct is_convertible;
template < bool, typename _Tp = void >struct enable_if
{
typedef _Tp type;
};
template < typename > void forward ();
}
class A;
class B
{
public:
A & getScheduler ();
};
class NetworkServer
{
NetworkServer ();
void run ();
};
namespace std
{
template < typename > class function;
}
template < typename > class Future;
using std::function;
using std::is_convertible;
using std::enable_if;
using std::__and_;
class A
{
public:
template <
typename
Func,
typename ... >auto
startThread ()->typename
enable_if <
is_convertible < Func, function < decltype (0) > >::pthread_t >::type;
template <
typename
MemberFunc,
typename
Class,
typename ...
Args >
auto
startThread (MemberFunc && func, Class * obj, Args
&& ... args)->enable_if < __and_ < >::value >::type
{
typedef
decltype ((obj->*func) (args ...))
ReturnType;
0 (function < ReturnType (Class *, Args ...) > (),
std::forward < Args > ...);
}
template <
typename
MemberFunc,
typename
Class,
typename ...
Args >
auto
startImportantThread (MemberFunc && func, Class * obj, Args
&& ... args)->enable_if < __and_ < >::value >::type
{
typedef
decltype ((obj->*func) (args ...))
ReturnType;
0 (function < ReturnType (Class *, Args ...) > (),
std::forward < Args > ...);
}
auto
submitSync ()->Future <
enable_if < __and_ < >::value, decltype (0) >::type >;
};
NetworkServer::NetworkServer ()
{
B *server;
server->getScheduler ().startImportantThread (&NetworkServer::run, this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment