[MUD-Dev] Re: lurker emerges

Vadim Tkachenko vt at freehold.crocodile.org
Tue Aug 11 23:33:37 CEST 1998


T. Alexander Popiel wrote:

[skipped]

> Unfortunately, I require (by my own free will, I'll admit) functionality
> in non-threaded environments, so the portability doesn't hold for me.
> However, we're just getting religious here, so I'll drop it. ;-)

My fault - I'm getting picky with the *terms* to achieve the
understanding, and usually forget to mention that upfront.

> >nor Java semaphores (they don't exist there)
> 
> *blink blink*
> 
> I suppose not, in the strictest sense, but I use the following
> construct all the time:
> 
>   Object sem = new Object();
>   synchronized (sem) {
>     /* pass sem to some other thread */
>     sem.wait();
>   }
> 
>   ...
> 
>   /* some other thread */
>   synchronized (sem) { sem.notify(); }
> 
> Tastes like a semaphore to me. ;-)

Looks like duck... :-)) In fact, yes, this is a mutex semaphore. As for
event semaphores, it's slightly different, and I had my own ideas about
the semantics, so I've implemented the sems in a pretty weird way.

One of the goals I wanted to achieve is to create a multiple-wait
semaphore, or semaphore group. It is possible to do this stuff in Java
without any additions, too, but it's the pain in the neck. And, as a
side effect, the observable/observer pattern applies here well, too. And
the callbacks.

And as it turned out, it was useful to implement even the mutex
semaphores (though they _do_ exist as the synchronized access) just to
make the design concept clearer. And to use them in the multiple-wait
conditions.

> - Alex

--
Still alive and smile stays on,
Vadim Tkachenko <vt at freehold.crocodile.org>
--
UNIX _is_ user friendly, he's just very picky about who his friends are




More information about the mud-dev-archive mailing list