Added asynchronous model of running scripts
This commit is contained in:
		
							parent
							
								
									01cf9243cf
								
							
						
					
					
						commit
						a234f2d5b2
					
				
					 5 changed files with 52 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -294,7 +294,6 @@ void EventThread::process(RGSSThreadData &rtData)
 | 
			
		|||
				rtData.rqReset.set();
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			keyStates[event.key.keysym.scancode] = true;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -420,6 +420,10 @@ struct FPSLimiter
 | 
			
		|||
private:
 | 
			
		||||
	void delayTicks(uint64_t ticks)
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		/* RETURN WITHOUT DOING ANYTHING */
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
#if defined(HAVE_NANOSLEEP)
 | 
			
		||||
		struct timespec req;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -358,6 +358,17 @@ struct InputPrivate
 | 
			
		|||
 | 
			
		||||
	void checkBindingChange(const RGSSThreadData &rtData)
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
		/* Run only once for emscripten. This is necessary due to *
 | 
			
		||||
 		 * a bug (in mutable?) that keeps reinitializing bindings */
 | 
			
		||||
		static bool once = false;
 | 
			
		||||
		if (!once)
 | 
			
		||||
			once = true;
 | 
			
		||||
		else
 | 
			
		||||
			return;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		BDescVec d;
 | 
			
		||||
 | 
			
		||||
		if (!rtData.bindingUpdateMsg.poll(d))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -150,13 +150,16 @@ int rgssThreadFun(void *userdata)
 | 
			
		|||
	/* Start script execution */
 | 
			
		||||
	scriptBinding->execute();
 | 
			
		||||
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	threadData->rqTermAck.set();
 | 
			
		||||
 | 
			
		||||
	threadData->ethread->requestTerminate();
 | 
			
		||||
 | 
			
		||||
	SharedState::finiInstance();
 | 
			
		||||
 | 
			
		||||
	alcDestroyContext(alcCtx);
 | 
			
		||||
	SDL_GL_DeleteContext(glCtx);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -345,6 +348,10 @@ int main(int argc, char *argv[])
 | 
			
		|||
	/* Start event processing */
 | 
			
		||||
	eventThread.process(rtData);
 | 
			
		||||
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* Request RGSS thread to stop */
 | 
			
		||||
	rtData.rqTerm.set();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue