Пример #1
0
bool hl_module_debug( hl_module *m, int port, bool wait ) {
	hl_socket *s;
	hl_socket_init();
	s = hl_socket_new(false);
	if( s == NULL ) return false;
	if( !hl_socket_bind(s,0x0100007F/*127.0.0.1*/,port) || !hl_socket_listen(s, 10) ) {
		hl_socket_close(s);
		return false;
	}
	debug_socket = s;
#	ifdef HL_THREADS
	hl_add_root(&debug_socket);
	hl_add_root(&client_socket);
	if( !hl_thread_start(hl_debug_loop, m, true) ) {
		hl_socket_close(s);
		return false;
	}
	if( wait ) {
		while( !debugger_connected )
			hl_sys_sleep(0.01);
	}
#	else
	// imply --debug-wait
	hl_debug_loop(m);
	hl_socket_close(debug_socket);
#	endif
	return true;
}
Пример #2
0
HL_PRIM vsentinel *HL_NAME(ui_start_sentinel)( double timeout, vclosure *c ) {
	vsentinel *s = (vsentinel*)malloc(sizeof(vsentinel));
	if( c->hasValue ) hl_error("Cannot set sentinel on closure callback");
#	ifdef HL_DEBUG
	timeout *= 2;
#	endif
	s->timeout = timeout;
	s->ticks = 0;
	s->original = hl_thread_current();
	s->callback = c->fun;
	s->thread = hl_thread_start(sentinel_loop,s,false);
	return s;
}