#1 2015-07-21 08:29:30

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Is crossplatform-mormot thread-safe?

I try to use crossplatform library in my multithread application...
and I get some strange access violation exceptions...

To start discussion I have one question:

Is crossplatform library thread-safe at all ?

Thanks.

Offline

#2 2015-07-21 09:31:32

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

Re: Is crossplatform-mormot thread-safe?

No it is not thread-safe by itself.

As soon as each thread has its own TSQLRestClientHTTP, it is thread safe.
Or you can protect the access to a single TSQLRestClientHTTP instance using a mutex/CriticalSection/TMonitor.

Offline

#3 2015-07-21 09:35:33

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Is crossplatform-mormot thread-safe?

Thanks a lot.

could you provide an example/manual/instruction please?

Offline

#4 2015-07-21 09:49:35

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Is crossplatform-mormot thread-safe?

Will Every thread have own TSQLRestClientHTTP with own server-session  (authentication, session id and so on) ?

Do you offer that?

Thanks a lot.

Offline

#5 2015-07-21 11:15:23

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

Re: Is crossplatform-mormot thread-safe?

Each TSQLRestClientHTTP instance maintains its own session.

So for a basic client, a single TSQLRestClientHTTP protected by TMonitor may be enough:

TMonitor.Enter(FClient);
try
  // protected code using FClient: TSQLRestClientHTTP 
finally
  TMonitor.Exit(FClient);
end;

Offline

#6 2015-07-21 12:02:07

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Is crossplatform-mormot thread-safe?

ok, thanks a lot for the help.
We will try.

Offline

Board footer

Powered by FluxBB