In article <199606181525.LAA05734@tabitha.atype.com> jsc@atype.COM (Jin S.
Choi) writes:
From: jsc@atype.COM (Jin S. Choi)
Newsgroups: comp.lang.scheme.scsh
Date: 18 Jun 1996 11:27:16 -0400
Organization: The Internet
Reply-To: jin@atype.com
Path:
news.cs.columbia.edu!news.columbia.edu!panix!bloom-beacon.mit.edu!INTERNET!news-mail-gateway
Lines: 21
Sender: inews-mailgate@bloom-beacon.mit.edu
Distribution: world
NNTP-Posting-Host: bloom-beacon.mit.edu
I'm interested in writing a multiuser game server using scsh, one
where clients can connect, log in, and interact with other
clients. This requires non-blocking sockets, so that the server can
process current clients while accepting new ones. As scsh doesn't
currently support threads, the only way I've found to be able to do
this is to use a big event loop,
Just say, "No!" to event loops. I think you will still need to
address the non-blocking socket issues, but you could add beauty to
your code and reduce the entropy in the universe by using
continuations.
Please see Matthew Fuchs' paper, "Escaping the event loop: an
alternative control structure for multi-threaded GUIs." He explains
why event loops with callbacks are difficult and confusing. This is
something many people, including me, have been arguing for years. In
his paper he does a very nice job of explaining how most imperative
languages force you into this convolution because they provide a
single, central stack. Threaded programs provide an alternative, but
add a level of complexity (locking resources) that really is not
necessary in most cases. Continuations allow you to write a thread of
control as if the i/o was synchronous, like terminal-based
applications, but in fact that control can be easily interleaved with
another. This is an important facility in user-interface design. But
go ahead and read his paper for a full explanation.
The example he uses to illustrate this is a multi-player, distributed
game of bridge. I suspect you could probably get a big boost by
adopting his program structure.
You can find the paper here:
http://galt.cs.nyu.edu/students/fuchs/
http://galt.cs.nyu.edu/students/fuchs/gui.ps
Cliff
--
Clifford Beshers Computer Graphics and User Interfaces Lab
beshers@cs.columbia.edu Department of Computer Science
http://www.cs.columbia.edu/~beshers Columbia University
|