doWindowEvents in a server app?

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Roger Parkinson >> Sat, 7 Aug 1999 5:42:28 GMT

Understandably you cannot do a doWindowsEvents() call in a server app. So what do you do when you want the server to wait for notifications? process.sleep() doesn't receive notifications (last time I tried it). Going into a tight loop seems like a performance hit (I might have a dozen of these things whirling around). So what do you do?

Roger

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Craig Shearer >> Sat, 7 Aug 1999 22:41:08 GMT

Just an idea, but why not call a clientExecution method to do a doWindowEvents

Would this work?

Since you're waiting to receive a notification the overhead of sending a message back to the client probably doesn't matter.

Let us know if this works.

Craig.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Krull >> Sun, 8 Aug 1999 23:11:58 GMT
Just an idea, but why not call a clientExecution method to do a doWindowEvents

Would this work?

Unlike a server method, a server application does not have an associated client-side process, so clientExecution is not really appropriate in this context. In a server method context, If you execute a doWindowsEvents from a clientExecution method call this will process windows events on the client node, not on the server; The server method will block waiting for the clientExecution method to exit and in this state cannot process other events.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Craig Shearer >> Mon, 9 Aug 1999 22:42:47 GMT

yep, completely misunderstood the original message... I thought he meant a server method, but on re-reading it he was of course referring to a server app.

Craig.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Krull >> Sun, 8 Aug 1999 21:55:13 GMT

Roger,

In JADE 5, you simply define your server application type to be 'Non-GUI'. The quiescent state for a nun-GUI appliction is 'waiting on an event'; Where an event could be a notification event, a timer event or an asynchronous Connection callback for example. A Non-GUI app can be terminated explicitly using the JADE terminate instruction.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Richard Mitchell >> Mon, 9 Aug 1999 0:32:59 GMT

Dear Mr McSkull

When using non-GUI apps (server applications) in JADE 5.0 I have found that the best way to simulate a doWindowEvents while in a long process loop is to set a timer running whose timerEvent will restart the process loop.

I'm not confident that using a notification to myself to perform the process loop restart would be reliable, because I don't know whether JADE guarantees that notifications are delivered to subscribers in the same order that they were issued, i.e. the restart notification might be processed before other outstanding notifications.

Richard Mitchell

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Krull >> Mon, 9 Aug 1999 0:57:24 GMT

Richard,

The notion of a 'doWindowsEvents' in a non-GUI app is a bit of a misnomer, since by definition there are no windows and therefore no events to process. It sounds like in your case you just want to break down a long processing loop into smaller subtasks. It is not clear from the above whether you simply want to relinquish control within the loop or whether you need to process other events such as notifications as well. If you require to relinquish control without processing other events, then a process.sleep will suffice. If you need to process other notifications, then separate server applications each dedicated to processing only one event at a time is simpler to manage. There are a several complexities (and risks) involved with "nested event" processing, as discussed on an earlier thread in one of the JADE newsgroups.

The use of timer events is certainly the way to schedule periodic tasks.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Roger Parkinson >> Mon, 9 Aug 1999 8:50:18 GMT

So is there a way to do it in Jade 4? I think Jade 5 has just arrived and the reply is certainly useful. However there might be reasons to not upgrade this week and I would like this one sorted out. Surely anyone who has built a server ap in Jade 4 has had to solve this one?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Richard Mitchell >> Mon, 9 Aug 1999 22:22:30 GMT

Roger

Yes, I have used the timerEvent technique to suspend processing in a server application in 4.2. After calling the beginTimer method you have to let your application go idle. The
timerEvent should be coded to resume your processing.

Richard Mitchell

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: doWindowEvents in a server app?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:17 pm

by Sean Dick >> Sun, 15 Aug 1999 23:40:27 GMT

I have implemented a scheduler in the manner that BeeJay describes in the next message.
A controllin app is idle and is woken by a timer event. It then decides if anybody needs to run and if so starts a new app instance for them. They then run off on there own the the controller goes idle until another timer event occurs.

This all works fine provided the process app only requires a single thread. If you want to do something between simple and complicated then it becomes a problem.

My example is that the process app is reading on an IP connection and issues a ReadBinaryAsync. I also set a timer to return after some timeout value. Neither of these events fire unless the process app is idle.

In my case the process is simple and I want to find the result immediately. In order to allow the events to fire the main thread has to go idle and then the simple process requires extra complexity to maintain it's states.

Easy to do but unneccessary in this instance. I bit of limitation with only one thread.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 0 guests