#1 2014-05-19 15:25:24

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

Asynchronous CRUD operations?

Hi Arnaud,

Can the object CRUD operation be asynchronous?

My application is a standalone program, some  threads will download something from the Internet and let the ORM server (using the named pipes protocol) to save the data.

And I don't want those 'downloader threads' to wait for the ORM server to finish saving data, but just post the job to the ORM and forget.


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

Online

#2 2014-05-19 18:24:01

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

Re: Asynchronous CRUD operations?

There is no such function yet.

You have to create your own thread for any asynchronous process.
You can use a library for that - like http://otl.17slon.com/

Offline

#3 2014-05-20 03:26:21

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

Re: Asynchronous CRUD operations?

@ab,

I think I just got my answer by a reply of yours in another topic, by setting the following:

TSQLRestServerDB.AcquireExecutionMode[execORMWrite] := amBackgroundThread

And all the writing to the sqlite3 db will be run in another single, dedicated background, thread, right?

Last edited by edwinsn (2014-05-20 03:50:56)


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

Online

#4 2014-05-20 03:53:36

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

Re: Asynchronous CRUD operations?

Oops, looks I myself is a little confused with my own question - with TSQLRestServerDB.AcquireExecutionMode[execORMWrite] := amBackgroundThread, the client still have to wait for the result of that background thread...

I already know the OTL threading library, but I want to make my program ready for inter-machine/process client/server architecture. I still need some thoughts...


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

Online

#5 2014-05-20 06:25:35

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

Re: Asynchronous CRUD operations?

Well, looks I can use threads on the client side too...


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

Online

#6 2014-05-20 06:33:01

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

Re: Asynchronous CRUD operations?

On the client side, there is some background process built-in.
See http://blog.synopse.info/post/2013/07/0 … responsive

Offline

#7 2014-05-20 10:25:16

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

Re: Asynchronous CRUD operations?

thanks for the info, that approach is not suitable for my case, I'll use threads on the client side.


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

Online

#8 2014-05-20 10:38:48

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

Re: Asynchronous CRUD operations?

Be aware that, in your case, I suppose each client thread should have its own TSQLRestClientURI instance, otherwise any shared instance will be blocking, so you will not benefit of multi-threading.

Offline

#9 2014-05-20 12:13:05

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

Re: Asynchronous CRUD operations?

ab wrote:

Be aware that, in your case, I suppose each client thread should have its own TSQLRestClientURI instance, otherwise any shared instance will be blocking, so you will not benefit of multi-threading.

Sure, and thanks!


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

Online

Board footer

Powered by FluxBB