syncExecInUI: - what equivalent in headless system ?

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

syncExecInUI: - what equivalent in headless system ?

Postby marten » Mon Jul 19, 2010 12:39 pm

Assuming, that I want to call an external library function with callbacks to Smalltalk in a headless image - these calls must be done in the UI process - but how is this done in a headless image, where CwAppContext is not available !?
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: syncExecInUI: - what equivalent in headless system ?

Postby Ralf » Mon Jul 26, 2010 2:27 am

I don't no whether it is possible or not. But, we have ported from vse do vast and in this context, we have implemented the event mechanism from vse like when:send:to. So you can trigger events from any object to any object without gui. I know, it will not help you, but is an information for you.:)
Ralf
 
Posts: 41
Joined: Thu Nov 16, 2006 4:18 am

Re: syncExecInUI: - what equivalent in headless system ?

Postby marten » Mon Oct 25, 2010 11:49 am

marten wrote:Assuming, that I want to call an external library function with callbacks to Smalltalk in a headless image - these calls must be done in the UI process - but how is this done in a headless image, where CwAppContext is not available !?


No answer available ? I know, that this is a very specific and special question: I want to call an external c library from Smalltalk and this library wants to call back into Smalltalk. Fine - from the documentation we know, that this call must be done from the UI process. Therefore to be sure, that your code is always executed (also from Smalltalk background processes) in the UI process, one will use CwAppContext default syncExecInUI: [ ] to ensure this.

But what is to do, if this feature is needed in a headless image ??? CwAppContext is not available in such an image ??? Or is a callback into Smalltalk in a headless image NOT possible ????
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: syncExecInUI: - what equivalent in headless system ?

Postby wembley » Tue Oct 26, 2010 4:46 am

Marten -

I guess I'm a little confused about what you are trying to do. Are you using the EsEntryPoint function to do the callbacks or EsPostAsyncMessage or ???
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC

Re: syncExecInUI: - what equivalent in headless system ?

Postby marten » Tue Oct 26, 2010 5:26 am

wembley wrote:Marten -

I guess I'm a little confused about what you are trying to do. Are you using the EsEntryPoint function to do the callbacks or EsPostAsyncMessage or ???


I'm calling an external C function and during this synchronous call I expect lots of callbacks (via EsEntryPoint).
The initiating call to the external function (when expecting callbacks) is done in the (Smalltalk-) UI process. ( I call it from the UI process, because I remember, that I have to do it ... but perhaps this assumption is wrong ?).

Now I'm creating a headless server image and I ask myself: when my assumption is correct and I had to make the call from the UI process: what is the UI process in a headless server.

The more I think about this, I consider my historical grown assumption is simply not correct.
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: syncExecInUI: - what equivalent in headless system ?

Postby PhotonDemon » Tue Oct 26, 2010 7:37 am

Hi Marten,

I think the equivalent of the of the UI process in a headless image is the process that is run when the program first starts. I don't know about Linux but in a windows NT service I call something like the code below from the method defined as the start method for the application.

Code: Select all
   mainProcessFlag := true.
...

   [self theCodeThatDoesTheWork] fork.

   delay := Delay forSeconds: 300.
   [mainProcessFlag] whileTrue: [
      delay wait.
      Processor finalizeCycle.
      System scavenge.
   ].


mainProcessFlag is an instance variable that can be set to false to let this starting process die. The loop at the bottom keeps this first (UI) process alive and every once in a while does some stuff to clean up memory.

I think that without that loop the process would die when it falls out the bottom. If I remember correctly, VA Smalltalk likes to have a UI process running and will create a new one if it dies. I think this is also true for non UI headless systems. Therefor if you make the setup call that you would normally do in the UI process in the startup method and keep it alive with the loop above, it should work close to the way things work in a real UI.

Lou
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:Lou@Keystone-Software.com http://www.Keystone-Software.com
PhotonDemon
[|]
 
Posts: 176
Joined: Thu Dec 20, 2007 1:45 pm


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest