December 2001
- Stories, why? -- Because :) Marian Griffith
- [SECURITY] Bonefarming Adam Martin
- If JRRT did MUDs... Adam Martin
- If JRRT did MUDs... Hans-Henrik Staerfeldt
- If JRRT did MUDs... Marcus Johansson
- Story Implementation Lee Sheldon
- Story Implementation rayzam
- Story Implementation Lee Sheldon
- Story Implementation Jeff Freeman
- Story Implementation Lee Sheldon
- Story Implementation Jeff Freeman
- Story Implementation Marian Griffith
- Story Implementation Jeff Freeman
- Story Implementation Jeff Cole
- Story Implementation Valerio Santinelli
- From the linux-kernel list Jeff Cole
- Survey: Internet Cuts Into TV Time Michael Tresca
- Interesting DAoC Poll Lee Sheldon
- Interesting DAoC Poll Vincent Archer
- Interesting DAoC Poll Robert Fleck
- Interesting DAoC Poll Azeraab
- Interesting DAoC Poll Matt Mihaly
- Interesting DAoC Poll Dave Shepherd
- Interesting DAoC Poll Azeraab
- Interesting DAoC Poll Dave Shepherd
- Interesting DAoC Poll Matt Mihaly
- Project announcement: Cool++ ryan daum
- DAoC: Empowering Players to Alter the World (was: New laws) Lee Sheldon
- DGN: Chemistry based magic systems Bryan "Cyngon" Helmkamp
- DGN: Chemistry based magic systems Nathan F. Yospe
- DGN: Chemistry based magic systems rayzam
- DGN: Chemistry based magic systems Bryan "Cyngon" Helmkamp
- DGN: Chemistry based magic systems Bryan "Cyngon" Helmkamp
- DGN: Chemistry based magic systems Sellers, Mike
- RuneSword Brian Hook
- Economic Growth (Was: [STORY] Story and population size) Daniel.Harman@barclayscapital.com
- Economic Growth (Was: [STORY] Story and population size) Elia Morling
- Economic Growth (Was: [STORY] Story and population size) Timothy Dang
- Economic Growth (Was: [STORY] Story and population size) Koster, Raph
- Economic Growth (Was: [STORY] Story and population size) John Buehler
- Economic Growth (Was: [STORY] Story and population size) Koster, Raph
- Economic Growth (Was: [STORY] Story and population size) John Buehler
- Economic Growth (Was: [STORY] Story and population size) Travis Nixon
- Economic Growth (Was: [STORY] Story and population size) Marian Griffith
- Economic Growth (Was: [STORY] Story and population size) Daniel.Harman@barclayscapital.com
- Economic Growth (Was: [STORY] Story and population size) Steve {Bloo} Daniels
- Economic Growth (Was: [STORY] Story and population size) Koster, Raph
- Economic Growth (Was: [STORY] Story and population size) Steve {Bloo} Daniels
- Economic Growth (Was: [STORY] Story and population size) Sellers, Mike
- Economic Growth (Was: [STORY] Story and population size) Matt Mihaly
- Economic Growth (Was: [STORY] Story and population size) Travis Nixon
- Economic Growth (Was: [STORY] Story and population size) Daniel.Harman@barclayscapital.com
- Economic Growth (Was: [STORY] Story and population size) Daniel.Harman@barclayscapital.com
- Economic Growth (Was: [STORY] Story and population size) Koster, Raph
- Economic Growth (Was: [STORY] Story and population size) Travis Nixon
- Economic Growth (Was: [STORY] Story and population size) Daniel.Harman@barclayscapital.com
- Economic Growth (Was: [STORY] Story and population size) Bobby Martin
- Economic Growth (Was: [STORY] Story and population size) Paul Schwanz
- Economic Growth (Was: [STORY] Story and population size) Peter Harkins
- Economic Growth (Was: [STORY] Story and population size) Daniel.Harman@barclayscapital.com
- Economic Growth (Was: [STORY] Story and population size) Travis Nixon
- RE : Story Implementation Veynom
- RE : Story Implementation Matt Mihaly
- RE : Story Implementation Matt Mihaly
- Economy (was [STORY] Story and population size) Jeff Cole
- Economy (was [STORY] Story and population size) Dave Rickey
- RE : Story Implementation Veynom
- RE : Story Implementation Matt Mihaly
- economy and population size Adam Martin
- economy and population size J C Lawrence
- Art vs. Fun Michael Tresca
- Art vs. Fun Koster, Raph
- Art vs. Fun Matt Mihaly
- Art vs. Fun Matt Mihaly
- Art vs. Fun Robert Zubek
- First use of "avatar"? Koster, Raph
- First use of "avatar"? Lars Duening
- First use of "avatar"? Matt Mihaly
- First use of "avatar"? Ola Fosheim Grøstad
- First use of "avatar"? Koster, Raph
- First use of "avatar"? Steve {Bloo} Daniels
- First use of "avatar"? Travis Casey
- First use of "avatar"? Koster, Raph
- First use of "avatar"? Christopher Kohnert
- First use of "avatar"? Travis Casey
- First use of "avatar"? Koster, Raph
- First use of "avatar"? Travis Nixon
- First use of "avatar"? Madman Across the Water
- First use of "avatar"? Takis Kalogiratos
- First use of "avatar"? Tamzen Cannoy
- First use of "avatar"? Dr. Cat
- First use of "avatar"? F. Randall Farmer
- First use of "avatar"? Mats Lidstrom
- First use of "avatar"? Koster, Raph
- First use of "avatar"? Nathan F. Yospe
- First use of "avatar"? Ola Fosheim Grøstad
- First use of "avatar"? Richard A. Bartle
- Managing MUD economy Vladimir Prelovac
- Managing MUD economy opteek
- Managing MUD economy Koster, Raph
- Managing MUD economy Derek Licciardi
- Managing MUD economy Bryan "Cyngon" Helmkamp
- Managing MUD economy Sasha Hart
- Managing MUD economy Vladimir Prelovac
- Managing MUD economy Freeman, Jeff
- Managing MUD economy John Buehler
- Managing MUD economy Marian Griffith
- Managing MUD economy Daniel.Harman@barclayscapital.com
- Managing MUD economy Adam Martin
- Managing MUD economy Sasha Hart
- Managing MUD economy Marc Hernandez
- Managing MUD economy Travis Casey
- Managing MUD economy Vladimir Prelovac
- Managing MUD economy Travis Casey
- Managing MUD economy William Murdick
- Managing MUD economy Timothy Dang
- MUD implementation issues. Marcus Johansson
- MUD implementation issues. J C Lawrence
- MUD implementation issues. Nicholas E. Walker
- MUD implementation issues. Phillip Lenhardt
- MUD implementation issues. Bruce Mitchener
- MUD implementation issues. Jonathan Berling
- MUD implementation issues. Bruce Mitchener
- MUD implementation issues. Marcus Johansson
- MUD implementation issues. Bruce Mitchener
- Economy Vincent Archer
- Ten Rules of PvP was Interesting DAoC Poll Azeraab
- Ten Rules of PvP was Interesting DAoC Poll Dave Shepherd
- Ten Rules of PvP was Interesting DAoC Poll Azeraab
- Ten Rules of PvP was Interesting DAoC Poll John Buehler
- Ten Rules of PvP was Interesting DAoC Poll Daniel.Harman@barclayscapital.com
- Ten Rules of PvP was Interesting DAoC Poll Vincent Archer
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Derek Licciardi
- MMORPGs & MUDs Sellers, Mike
- MMORPGs & MUDs Brian Hook
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Sellers, Mike
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Derek Licciardi
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Lee Sheldon
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Mike Caruso
- MMORPGs & MUDs Adam Martin
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Jeff Freeman
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Jeff Freeman
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Jeff Freeman
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Madrona Tree
- MMORPGs & MUDs John Buehler
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs David H. Loeser Jr.
- MMORPGs & MUDs Daniel.Harman@barclayscapital.com
- MMORPGs & MUDs Freeman, Jeff
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Vincent Archer
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs Vincent Archer
- MMORPGs & MUDs Sellers, Mike
- MMORPGs & MUDs rayzam
- MMORPGs & MUDs Sellers, Mike
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs William B. Taylor
- MMORPGs & MUDs Skaei@aol.com
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs Madrona Tree
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Christopher Allen
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs J C Lawrence
- MMORPGs & MUDs J C Lawrence
- MMORPGs & MUDs Vincent Archer
- MMORPGs & MUDs Dave Rickey
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Richard Aihoshi aka Jonric
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Sellers, Mike
- MMORPGs & MUDs Marc Bowden
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Marc Bowden
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs David Bennett
- MMORPGs & MUDs Marc Bowden
- MMORPGs & MUDs Freeman, Jeff
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Jeff Freeman
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Matt Mihaly
- MMORPGs & MUDs Wes Connell
- MMORPGs & MUDs Koster, Raph
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs J C Lawrence
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs Joel Palmtag
- MMORPGs & MUDs J C Lawrence
- MMORPGs & MUDs Michael Tresca
- MMORPGs & MUDs J C Lawrence
- MMORPGs & MUDs Michelle Elbert
- MMORPGs & MUDs Sami Kosonen
- MMORPGs & MUDs Azeraab
- MMORPGs & MUDs Sellers, Mike
- MMORPGs & MUDs J C Lawrence
- Re[4]: Economy Travis Casey
- Eiffel Brian Hook
- ADMIN: Origin of "Avatar" thread J C Lawrence
- Call for Papers - NetGames2002 Tristan Henderson
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Brian Hook
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Koster, Raph
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Koster, Raph
- Continuous versus Discrete Functions rayzam
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Travis Casey
- Continuous versus Discrete Functions Caliban Tiresias Darklock
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Caliban Tiresias Darklock
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Daniel.Harman@barclayscapital.com
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Andrew Hefford
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Koster, Raph
- Continuous versus Discrete Functions Jon Lambert
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Koster, Raph
- Continuous versus Discrete Functions Dave Rickey
- Continuous versus Discrete Functions Daniel.Harman@barclayscapital.com
- Continuous versus Discrete Functions Dave Rickey
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions Dave Rickey
- Continuous versus Discrete Functions John Buehler
- Continuous versus Discrete Functions rayzam
- Continuous versus Discrete Functions Caliban Tiresias Darklock
- Continuous versus Discrete Functions kyndig@kyndig.com
- Continuous versus Discrete Functions Caliban Tiresias Darklock
- Continuous versus Discrete Functions Jon Lambert
- Continuous versus Discrete Functions Peter Harkins
- Continuous versus Discrete Functions Travis Casey
- Continuous versus Discrete Functions Caliban Tiresias Darklock
- LPC-Natural Language Parser z032383@students.niu.edu
- [TECH] Event Queues in MUDs Daniel.Harman@barclayscapital.com
- [TECH] Event Queues in MUDs Jon Lambert
- [TECH] Event Queues in MUDs Christian Loth
- [TECH] algorithm request Malcolm Tester II
- [TECH] algorithm request William Murdick
- [TECH] algorithm request Lars Duening
- [TECH] algorithm request David Bennett
- [TECH] algorithm request Travis Casey
- [TECH] algorithm request Malcolm Tester II
- [TECH] algorithm request Adam Martin
- [TECH] algorithm request Eli Stevens
- [TECH] algorithm request Bobby Martin
- [TECH] algorithm request Bryan "Cyngon" Helmkamp
- non-'realistic' spatial models Nicholas E. Walker
- non-'realistic' spatial models rayzam
- non-'realistic' spatial models Hans-Henrik Staerfeldt
- non-'realistic' spatial models Cybrarian Rök
- non-'realistic' spatial models Nathan F. Yospe
- The Problem With "Massive" Michael Tresca
- The Ideal Player Michael Tresca
- The Ideal Player Lars Duening
- The Ideal Player Dave Rickey
- The Ideal Player Caliban Tiresias Darklock
- [Theory?] Parsing of knowledge to allow for more interactive NPCs holding99@mindspring.com
- [Theory?] Parsing of knowledge to allow for more interactive NPCs Robert Zubek
- [Theory?] Parsing of knowledge to allow for more interactive NPCs holding99@mindspring.com
- CHI 2002: Funology: Designing Enjoyment Bruce Mitchener
- CHI 2002: Funology: Designing Enjoyment Bruce Mitchener
- CHI 2002: Funology: Designing Enjoyment Ola Fosheim Grøstad
- [OFF TOPIC] Happy Holidays Derek Licciardi
- Are crafts fun? Adam Dray
- Are crafts fun? Michelle
- Are crafts fun? Bobby Martin
- Are crafts fun? Bobby Martin
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Jon A. Lambert
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) amanda@alfar.com
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Marian Griffith
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Caliban Tiresias Darklock
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Marian Griffith
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Caliban Tiresias Darklock
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Marian Griffith
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Caliban Tiresias Darklock
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Paul Schwanz - Enterprise Services
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Caliban Tiresias Darklock
- Gender differences -> spatial navigation rayzam
- Gender differences -> spatial navigation amanda@alfar.com
- Gender differences -> spatial navigation Nathan F. Yospe
- Sex and MUDs... the_sage2000@juno.com
- Sex and MUDs... Jon Lambert
- Sex and MUDs... David Bennett
- Sex and MUDs... Travis Casey
- Sex and MUDs... Malcolm Tester II
- Sex and MUDs... Matt Mihaly
- Sex and MUDs... Adam Dray
- Some vworlds (maddog) related changes Frank Crowell
- Some vworlds (maddog) related changes Frank Crowell
- (no subject) claw@kanga.nu
From shren@fnord.io.com Fri Apr 27 23: 08:29 2001
Return-Path: <shren@fnord.io.com>
Received: from anarchy.io.com (anarchy.io.com [199.170.88.101])
by bush.kanga.nu (Postfix) with ESMTP id 473AF351A4
for <mud-dev@kanga.nu>; Fri, 27 Apr 2001 23:08:29 -0700 (PDT)
Received: from deliverator.io.com (root@deliverator.io.com [199.170.88.17])
by anarchy.io.com (8.9.3/8.9.3) with ESMTP id BAA16218
for <mud-dev@kanga.nu>; Sat, 28 Apr 2001 01:08:27 -0500
Received: from fnord.io.com (IDENT:shren@fnord.io.com [199.170.88.12])
by deliverator.io.com (8.9.3/8.9.3) with ESMTP id BAA31460
for <mud-dev@kanga.nu>; Sat, 28 Apr 2001 01:08:23 -0500
Received: from localhost (shren@localhost)
by fnord.io.com (8.8.7/8.8.7) with ESMTP id BAA25101
for <mud-dev@kanga.nu>; Sat, 28 Apr 2001 01:08:22 -0500
Date: Sat, 28 Apr 2001 01:08:22 -0500 (CDT)
From: shren <shren@io.com>
To: mud-dev@kanga.nu
Subject: Re: [MUD-Dev] Re: TECH: Distributed Muds
In-Reply-To: <30426.988420819@2wire.com>
Message-ID: <Pine.LNX.4.21.0104280008170.18108-100000@fnord.io.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Resent-To: mud-dev@kanga.nu
Resent-Date: Sun, 23 Dec 2001 23:41:34 -0800
Resent-Message-ID: <4054.1009179694@kanga.nu>
Resent-From: J C Lawrence <claw@kanga.nu>
<EdNote: This is an old message that Mailman somehow diverted
without my noticing>
On Fri, 27 Apr 2001, J C Lawrence wrote:
> On Fri, 27 Apr 2001 12:57:43 -0400
> Derek Snider <derek@idirect.com> wrote:
>> Threaded/multi-process MUDs are a completely different story.
>> It's like comparing apples and oranges.
> Given a threaded IO setup with only two threads (IO gathering and
> game process), the delta really isn't that large.
I concurr. Designing entire architectures that have 30,000 threads
dancing in harmony is very, very tricky. But threading is very
useful when you are making a thread to solve a reasonably
modularized problem that has to happen (or would be better
happening) independantly from the rest of execution.
The classic example is sound. If you're writing some code that
deals with sound buffers directly, then you can either check the
sound buffers constantly in your code, to make sure your 2 second
sound buffer stays full with new sound, or you can push it off in a
seperate thread. (I'd swear that Ultima 9 had sound in the main
thread. I'm not *certain*, but the way things would skip sometimes,
it seemed very likely.)
I find the key to working with threads is state diagrams. Your
threads have to clearly be in one state or another, to make a
coherent design.
Since I've recently been told that long posts are ok, I'll dump some
code here that I wrote to do simple interaction with threads. I'm
not saying it's the best code, but I get by with it. (Actually, I'm
not even sure this is the best version of my code.)
Note : this is windows code, but the principles are similar in the
UNIX world.
This is far from the best code you'll find. Books big enough to do
mugging in Central Park are introductions to the subject. The
reason I think it will be interesting for those who don't know
threads is that it is the smallest modular implementation of
threading I could come up with. We never launched a project that
*uses* this code, however, so I can't guarantee stability. It
served, however, all the way up to the point where we realized that
our product would draw lawsuits like flies and abandoned it. I look
back now and see some things I'd change, but all code is like that.
I've got some other thread code that is object based, developed from
this code, where you can make an object have it's own thread by
having it inherit the "runnable" class, but I think this older code
is better for a c sample, as it abuses the c++ class structure for
it's advantages to essentially write c style code.
Here's how you might use this code. As for communicating between
the thread and the outside world, the best thing to do is to make
your favorite queue class threadsafe and then put instances of it
inside y, below. Since the queues are threadsafe, the thread can
push things onto them and you can pop things outside outside of the
thread.
Below, three functions are declared. Init, loop, and end. These
functions are passed as pointers to the object. The first is run
once. The second is run as a loop when hGo is set. The third is
triggered when CThread goes out of scope (x is deleted).
CThread *x;
void init(void *) {//this function is run once at the beginning}
void loop(void *) {//this function is run as the main loop}
void end(void *) {//this function is run at the end}
struct something y;
x = new CThread("blah", // an arbitrary (should be unique) thread name
&y, // this pointer is passed to init, loop, and end
init,loop,end // function pointers
);
//init(y) is run in the thread at this point
// tell it to start - these three statements should be a method of
// CThread and *not* accessed externally. Thing one I'd change -
// making a start method and a stop method inside the class.
// Exercise to the reader, and all that.
HANDLE hGo;
OpenEvent(NULL,FALSE,"blah_go");
SetEvent(hGo);
//do other stuff here. while you do,
//loop(y) is run repeatedly untill....
delete x;
//loop(y) finishes if it is currently running.
//end(y) is run.
//here's the 4 source files.
/* Thread.h begin */
#include "stdafx.h"
#include "threadproc.h"
#ifndef _thread_class_h_
#define _thread_class_h_
unsigned __stdcall threadproc(void *lpThreadParameter);
class CThread
{
friend unsigned __stdcall threadproc(void *lpThreadParameter);
protected:
HANDLE hIdle,hEnd,hEndAck,hChild;
HANDLE hGo;
char szIdle[16],szEnd[16],szEndAck[16];
char szWait[16];
unsigned int id;
void *pass;
void (*start)(void *);
void (*loop)(void *);
void (*end)(void *);
struct threadinfo ti;
public:
CThread();
CThread(char *name, void *data,
void(*a)(void *),void(*b)(void *),void(*c)(void *));
virtual ~CThread();
};
#endif
/* Thread.h end */
/* Threadproc.h begin */
#ifndef _threadproc_h_
#define _threadproc_h_
unsigned int __stdcall threadproc(void *x);
struct threadinfo {
char szIdle[16];
char szEnd[16];
char szEndAck[16];
char szGo[16];
void (*start)(void *);
void (*loop)(void *);
void (*end)(void *);
void *data;
};
#endif
/* Threadproc.h end */
/* Thread.cpp begin */
#include "stdafx.h"
#include "Thread.h"
#include "threadproc.h"
CThread::CThread()
{
}
CThread::CThread(char *name, void *data, void(*a)(void *),
void(*b)(void *),void(*c)(void *))
{
ODS("thread constructor\n");
pass = data;
// store the function pointers and the data pointer.
ti.start = a;
ti.loop = b;
ti.end = c;
ti.data = data;
// create the event names.
sprintf(ti.szIdle,"%s_idle",name);
sprintf(ti.szEnd,"%s_end",name);
sprintf(ti.szEndAck,"%s_end_ack",name);
sprintf(ti.szGo,"%s_go",name);
// create the thread running threadproc()
hChild = (HANDLE)(
_beginthreadex(NULL,0,threadproc,(void *)&ti,CREATE_SUSPENDED,&id)
);
// events
// this indicates that the thread is idle when set.
// if you want to modify the data outside the class,
// then you can, outside the class, Reset the go
// event then wait for the Idle event.
hIdle = CreateEvent(0,TRUE,FALSE,ti.szIdle);
ResetEvent(hIdle);
// end and endack are used for synchronous shutdown
hEnd = CreateEvent(0,TRUE,FALSE,ti.szEnd);
ResetEvent(hEnd);
hEndAck = CreateEvent(0,TRUE,FALSE,ti.szEndAck);
ResetEvent(hEndAck);
// to execute the loop or not execute the loop?
hGo = CreateEvent(0,TRUE,FALSE,ti.szGo);
ResetEvent(hGo);
// make the thread start
ResumeThread(hChild);
}
CThread::~CThread()
{
ODS("destructor\n");
WaitForSingleObject(hIdle,INFINITE);
ODS("thread is idle\n");
SetEvent(hEnd);
WaitForSingleObject(hEndAck,INFINITE);
ODS("thread is terminated\n");
}
/* Thread.cpp end */
/* Threadproc.cpp begin */
#include "stdafx.h"
#include "Thread.h"
#include "threadproc.h"
unsigned int __stdcall threadproc(void *in)
{
HANDLE hIdle, hEnd, hEndAck, hGo;
HRESULT hr;
struct threadinfo *pass;
pass = (struct threadinfo *)in;
// open copies of the events made inside the class.
hIdle = OpenEvent(EVENT_MODIFY_STATE,FALSE,pass->szIdle);
if (hIdle == 0) {ODS("dead idle handle!\n");}
hEnd = OpenEvent(EVENT_MODIFY_STATE,FALSE,pass->szEnd);
if (hEnd == 0) {ODS("dead end handle!\n");}
hEndAck = OpenEvent(EVENT_MODIFY_STATE,FALSE,pass->szEndAck);
if (hEndAck == 0) {ODS("dead endack handle!\n");}
hGo = OpenEvent(EVENT_MODIFY_STATE,FALSE,pass->szGo);
if (hGo == 0) {ODS("dead wait handle!\n");}
// run the start function the user passed us
pass->start(pass->data);
while (0==0)
{
// if we can go, run the main loop once
hr = WaitForSingleObject(hGo,0);
if (hr == WAIT_OBJECT_0)
{
pass->loop(pass->data);
}
// we are idle
SetEvent(hIdle);
// let the other processes have some time
Sleep(0);
// check if we've been instructed to terminate
hr = WaitForSingleObject(hEnd,0);
if (hr == WAIT_OBJECT_0)
{
SetEvent(hEndAck);
pass->end(pass->data);
_endthreadex(0);
}
// we are no longer idle
ResetEvent(hIdle);
}
return 0;
}
/* Threadproc.cpp end */
--
Give a man a fish, and you feed him for a day.
Teach a man to fish, and you've created competition.
Competition keeps you on your toes. - Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Caliban Tiresias Darklock
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) amanda@alfar.com
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Caliban Tiresias Darklock
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Marian Griffith
- Boys and Girls - was (MUD-Dev digest, Vol 1 #16 3 - 25 msgs) Sellers, Mike
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) Caliban Tiresias Darklock
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) amanda@alfar.com
- Boys and Girls - was (MUD-Dev digest, Vol 1 #163 - 25 msgs) mystran@ltv.cx
- Combat system in persistent world Veynom
- Combat system in persistent world J C Lawrence
- Taligent docs Bruce Mitchener
- Taligent docs Chris Corry
- TECH: Servers in Java Brian Hook
- TECH: Servers in Java Bruce Mitchener
- TECH: Servers in Java Brian Hook
- TECH: Servers in Java Bobby Martin
- TECH: Servers in Java Emil Eifrem
- TECH: Servers in Java Aaron Mulder
- TECH: Servers in Java justice@softhome.net
- TECH: Servers in Java Brian Hook
- TECH: Servers in Java Daniel.Harman@barclayscapital.com