#1 2014-05-18 11:29:20

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Will ExportServerNamedPipe() make the server runs another thread?

Hi Arnaud,

In my standalone program, I'm creating running TSQLRestServerDB.ExportServerNamedPipe() in a separated thread, but just now I checked the source code of that function, it seems that ExportServerNamedPipe() will create another thread.

Does it mean I can simply run ExportServerNamedPipe() in my the main thread, and the server will automatically runs in a separated thread?

Couldn't find related info in the manual. Sorry.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2014-05-18 12:21:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Will ExportServerNamedPipe() make the server runs another thread?

Yes the method creates its own thread so you do not need to create your own.

Offline

#3 2014-05-18 14:22:06

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Will ExportServerNamedPipe() make the server runs another thread?

One more question, ab, ExportServerMessage() doesn't create its own thread, right?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2014-05-18 14:41:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Will ExportServerNamedPipe() make the server runs another thread?

No, AFAIK ExportServerMessage() uses the main Windows Message loop, so it runs in the main thread, just like any windows application using messages.

Offline

#5 2014-05-18 15:34:01

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Will ExportServerNamedPipe() make the server runs another thread?

thanks for the info, Arnaud.

PS 1, it seems that a windows message-based server (ExportServerMessage()) doesn't work inside a TOmniWorker (of OTL - OmniThreadLibrary), I tried that, and when a client access that server from the main thread, the program will hang. Maybe it conflicts with OTL's message loops... Anyways, just a report to you, I use the named pipe protocol now.

PS 2,  you seem to use the term 'GDI message', but a Google search didn't show any results about it, I guess the more proper term should be 'win32 message', or 'winapi message', or 'Windows message'? This occurred to me when replying you, so I figured I'd mention it smile

Last edited by edwinsn (2014-05-18 15:34:41)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#6 2014-05-18 18:25:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Will ExportServerNamedPipe() make the server runs another thread?

PS 2 - it has been fixed two days ago (if I remember well), and changed the documentation into "Windows Message".
But I just checked the source, and there was still some occurrences.
See http://synopse.info/fossil/info/010f6771d7

It should be fixed now.
Thanks for the feedback.

Offline

#7 2014-05-19 16:04:47

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Will ExportServerNamedPipe() make the server runs another thread?

Thanks, ab, one more question, if you don't mind.

If I define a server side function, eg, TSQLRestServerDB.Sum(), will this  function runs in the thread created by ExportServerNamedPipe() ?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#8 2014-05-19 18:20:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Will ExportServerNamedPipe() make the server runs another thread?

For a method-based services, it runs by default in the calling thread (i.e. the one used for Named Pipe communication).
But you can change it setting a value to TSQLRestServer.AcquireExecutionMode[execSOAByMethod] property (by default, this is amUnlocked).

For interface-based services, you have even more options.

All this is explained in the SAD 1.18 pdf.

Offline

Board footer

Powered by FluxBB