Re: Single instance module and multithreading

From: Alex <alex.bep....at.gmail.com>
Date: Sun, 22 Feb 2009 23:42:50 -0800 (PST)

> Right now it closes the server after receiving a single connection.
> This will need to be fixed of course, but I don't know how to accept
> clients in a while loop while still closing the server on exit.

Do you need to explicitly close the server on exit? I had no problems
not doing so. I put the while loop in a lane too, cp.
putFileNamesInQueue().

- Alex

On Feb 23, 3:15 am, mitchell <mforal.n....at.gmail.com> wrote:
> Hi,
>
> > You are correct. I guess I am still unsure as to how exactly Lanes
> > functions. I am thinking passing by reference, not by value. It
> > appears Linda and executing commands on 'view_switch' is the way to
> > go.
>
> This version has been tested and works. I placed it inside the 'if not
> RESETTING' conditional inside init.lua.
> Right now it closes the server after receiving a single connection.
> This will need to be fixed of course, but I don't know how to accept
> clients in a while loop while still closing the server on exit.
>
>   require 'socket'
>   require 'lanes'
>   local linda = lanes.linda()
>   local port = 3000
>   function lane()
>     local socket = require 'socket'
>     local server = socket.bind('localhost', port)
>     local client = server:accept()
>     linda:send('command', client:receive())
>     server:close()
>   end
>   local l = lanes.gen("*", lane)()
>   textadept.events.add_handler('view_switch',
>     function()
>       cmd = linda:receive(0, 'command')
>       while cmd do
>         pcall(loadstring(cmd))
>         cmd = linda:receive(0, 'command')
>       end
>     end)
>
Received on Mon 23 Feb 2009 - 02:42:50 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:37:32 EST