If you prefix the first `while` with `@async` then they will run in
separate tasks, and their blocking operations will be logically concurrent.

On Wed, Jun 22, 2016 at 3:19 AM, Jon Norberg <[email protected]>
wrote:

> I am trying to use a websocket to provide online input to a simulation
> that runs on another process and update back with a given frequency. The
> examples I have found all wait for a read event and then immediately write
> back. I would like to have the ability to have separate read and write
> loops (or any other method to achieve the same thing), essentially running
> these loops or equivalent simultaneously (preferably even possibly on
> separate processes):
>
> while true
>   msg=read(client)
>   put!(msg into channel)
> end
>
> while true
>   take!(msg from channel)
>   write(client, msg)
>   sleep(0.1)
> end
>
>  I want the web socket to communicate with the simulation via a channel
> but I am not sure if this is the best way. The simulation runs in real time
> and will only be affected by user input if any info comes through the web
> socket but the user can see the simulation in near realtime with or without
> input.
>
> Any help much appreciated!

Reply via email to