当前位置: 首页>>代码示例>>C++>>正文


C++ object::push方法代码示例

本文整理汇总了C++中luabind::object::push方法的典型用法代码示例。如果您正苦于以下问题:C++ object::push方法的具体用法?C++ object::push怎么用?C++ object::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在luabind::object的用法示例。


在下文中一共展示了object::push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: thread_func

void xd::lua::scheduler::start(luabind::object func)
{
	// create a new thread
	lua_State *thread = lua_newthread(m_vm.lua_state());
	// push the function in the new thread, because the function
	// the thread calls must be called in its local environment
	func.push(thread);
	// construct a callable object from it, the value is copied from stack
	luabind::object thread_func(luabind::from_stack(thread, -1));
	// remove the original value from the stack
	lua_pop(thread, 1);
	// set the current thread
	m_thread_stack->threads.push(thread);
	m_current_thread = thread;
	// start the thread
	luabind::object result = luabind::resume_function<luabind::object>(thread_func);
	// if the thread was yielded from lua side, and the return value is a callable function
	int type = luabind::type(result);
	if (type == LUA_TFUNCTION || type == LUA_TTABLE || type == LUA_TUSERDATA) {
		yield(xd::create<detail::callback_task_lua>(result));
	}
	// reset current thread
	m_thread_stack->threads.pop();
	if (m_thread_stack->threads.empty())
		m_current_thread = nullptr;
	else
		m_current_thread = m_thread_stack->threads.top();
}
开发者ID:Greyze,项目名称:xd,代码行数:28,代码来源:scheduler.cpp

示例2: start

// TODO Move arguments from constructor to here?
void timer::start(luabind::object& f)
{
  thread = player->create_lua_thread();
#ifndef NDEBUG
  int old_top = lua_gettop(thread);
#endif
  //function.push(thread);
  f.push(f.interpreter());
  lua_xmove(f.interpreter(), thread, 1);
  assert(old_top + 1 == lua_gettop(thread));

  timer_thread = boost::thread(&timer::count_down, this);
}
开发者ID:alyssonbrito,项目名称:linux-opengl-player,代码行数:14,代码来源:timer.cpp


注:本文中的luabind::object::push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。