int main() { remote::session session; client_target tc1("c1"); boost::shared_ptr<client_target> tc2 = boost::make_shared<client_target>("c2"); boost::shared_ptr<rmt> c1 = session.bind<rmt>(&tc1); boost::shared_ptr<rmt> c2 = session.remote_cast<rmt>(tc2); session.start(remote::make_tcp_binding("localhost", 8888)); if(session.wait_for_ready() != remote::session::started) return -1; boost::shared_ptr<rmt> s1 = session.get<rmt>("s1"); boost::shared_ptr<rmt> s2 = session.get<rmt>("s2"); boost::shared_ptr<remote_test> test = session.get<remote_test>("test"); test->set_rmt_ptr(c1); boost::shared_ptr<rmt> rc1 = test->get_rmt_ptr(); rc1->invoke("client"); test->set_rmt_ptr(s1); boost::shared_ptr<rmt> rs1 = test->get_rmt_ptr(); rs1->invoke("client"); std::vector<boost::shared_ptr<rmt> > v; v.push_back(c1); v.push_back(s1); v.push_back(c2); v.push_back(s2); test->invoke_all(v); return 0; }
bool checkT2P(const Rect& viewport, const Matrix& vp, const vertexPCT2* v1, const vertexPCT2* v2, int w, int h) { Vector3 p1(v1->x, v1->y, 0); Vector3 p2(v2->x, v2->y, 0); p1 = vp.transformVec3(p1); p2 = vp.transformVec3(p2); Vector2 half = viewport.getSize().cast<Vector2>() / 2; p1.x = p1.x * half.x + half.x; p1.y = p1.y * half.y + half.y; p2.x = p2.x * half.x + half.x; p2.y = p2.y * half.y + half.y; Vector2 tc1(v1->u, v1->v); Vector2 tc2(v2->u, v2->v); Vector3 dp_ = p1 - p2; Vector2 dp(dp_.x, dp_.y); dp.x = scalar::abs(dp.x); dp.y = scalar::abs(dp.y); Vector2 dtc = tc1 - tc2; dtc.x = scalar::abs(dtc.x) * w; dtc.y = scalar::abs(dtc.y) * h; const float EPS = 0.05f; Vector2 d = dp - dtc; if (scalar::abs(d.x) >= EPS || scalar::abs(d.y) >= EPS) return false; p1.x = scalar::abs(p1.x); p1.y = scalar::abs(p1.y); if (scalar::abs(p1.x - int(p1.x + EPS)) > EPS || scalar::abs(p1.y - int(p1.y + EPS)) > EPS) return false; return true; }
static void test_threadex(void) { struct ymsglooper *ml; struct ymsghandler *mh; srand(time(NULL)); ml = ymsglooper_start_looper_thread(FALSE); mh = ymsghandler_create(ml, NULL); /* use default handle */ tc1(mh); tc2(mh); tc3(mh); tc4(mh); /* clean up all others */ ymsghandler_destroy(mh); ymsglooper_stop(ml); while (YMSGLOOPER_TERMINATED != ymsglooper_get_state(ml)) usleep(10*1000); ymsglooper_destroy(ml); }