Mark,

Thanks for the feedback. That's exactly the kind of design I was looking
at implementing. I'll keep your point #2 in mind, as my thinking process
has not quite reached that stage yet:)

Thanks,

Patrick


On Thu, 2003-11-20 at 09:25, Mark Fowler wrote:
> On Thu, 20 Nov 2003, Patrick LeBoutillier wrote:
> 
> > suggestions
> 
> I had a long think about this when I couldn't get it to work and came to
> roughly the same conclusions as you.  Here's what I came up with, just
> incase you're still looking for feedback.
> 
>  1) The simpliest implementation is a MainLoop object that has a mainloop
>     method that is called from perl and does nothing but waiting on a
>     queue.  Waiting could probably be achieved by using wait and notifiy
>     and every time MainLoop's addThingy method is called it adds the
>     passed thingy to the end of the queue and notifies the object that
>     the mainloop method is waiting on.  The thingy you're adding to the
>     queue could simply hold an Object, a Method, and a array of
>     arguemtents which could then be invoked by mainloop when it wakes
>     up by calling thingy.getMethod().invoke(thingy.getObject(),
>                                             thingy.getArgs())
> 
>  2) It'd be nice to write things like ActionListenerProxy that you
>     construct by passing in the mainloop and the object you want the event
>     proxied to.
> 
>     For example, ActionListenerProxy would look something like this
>     (warning totally untried code that I wrote directly in my mail
>      client and hence am lost without syntax highlighting):
> 
>     package ActionListenerProxy
>     {
>        Mainloop mainloop;
>        ActionListener actionListener
> 
>        public ActionListenerProxy(Mainloop mainloop,
>                                   ActionListener actionListener)
>        {
>           this.mainloop       = mainloop;
>           this.actionListener = actionListener;
>        }
> 
>        void actionPerformed(ActionEvent e)
>        {
>           Class  actionEventClass = e.getClass();
>           Class  argTypes[]       = { actionEventClass };
>           Object args[]           = { e };
> 
>           // get the "actionPerformed" method for our class
>           Method actionPerformedMethod =
>               actionListener.getClass()
>                             .getMethod("actionPerformed",argTypes);
> 
>           // schedule a thingy to be called by the mainloop
>           mainloop.addThingy(
>              new Thingy(actionListener,
>                         actionPerformedMethod,
>                         args)
>           );
>        }
>     }
> 
> Mark.
-- 
=====================
Patrick LeBoutillier
Laval, Qu�bec, Canada

Reply via email to