[erlang-questions] Driver Threading & Message Sending

Benjamin Tolputt bjt@REDACTED
Tue Sep 18 02:48:52 CEST 2007

More questions though this time (while related to Stand Along Erlang, it 
also applies to general Erlang driver stuff I am developing).

The benefit of Erlang which are pushing me to evangelize it to the game 
development crew is the high concurrency and CPU utilization on 
multi-core machines (i.e. it's SMP capabilities). To this end, they 
asked if it would be possible for them to run their physics & AI modules 
in a separate started up in a Erlang driver. This seems quite possible, 
but I wanted to know a couple of things about how threading & drivers 
are allowed to operate.

Let's say that a driver is created for the AI engine utilizing whatever 
techniques they desire for this. Let's also assume that they are running 
this in a permanent loop (the classic "while (true)" thing) with input 
coming in from Erlang through the driver interface and sending messages 
back out the same way.

Is it safe for the driver code to call the "driver_output" function from 
a thread other than one in which the emulator "calls into" the driver 
(i.e. is it possible to call driver_output from a thread not started by 
the emulator)? If not, what is the common method used to get output 
generated by the driver independent of queries (i.e. a call to the 
drv_output driver callback) from Erlang? Polling for output from the 
driver seems a bit strange given the message-centric method of 
everything else, but I haven't been this low-level with Erlang before...


More information about the erlang-questions mailing list