#1 2019-12-18 17:24:01

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Interfaced method syncronisation

Hi,

I'm asking this and maybe this is a stupid question:
We need to implement sicSingle service (multithreaded) and each call (same method) should wait for previous to end:
We get 1., 2., 3., ... n. call ... 1. is processing and others should wait and when the 1. ends, 2. comes in.
Is this already implemented in Mormot ?
We want to stay in method until it finishes or timeouts.

Or does someone has better idea ?

Thank you,
Vojko Cendak

Offline

#2 2019-12-18 18:31:37

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 332

Re: Interfaced method syncronisation

We are using sicShared and when we need serialized access to somene services we use TSynLocker.Lock and TSynLocker.Unlock in a try .. finally.


Esteban

Offline

#3 2019-12-18 21:47:48

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: Interfaced method syncronisation

I believe that this topic in the documentation will help you:

https://synopse.info/files/html/Synopse … l#TITL_152

Offline

#4 2019-12-20 14:10:07

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Re: Interfaced method syncronisation

Thank you,

sicShared works this way but then another mothods are also blocked.

sicSingle:
We solved it with application logic, eg. per mothod calls managment, timoeut, max number of wait in que.

Is there posibility to get count of currently executing methods by name or ... ?

Thank you all,
Vojko Cendak

Offline

#5 2019-12-20 14:37:16

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 332

Re: Interfaced method syncronisation

sicShared works this way but then another mothods are also blocked.

Using lock/unlock inside the endpoint of interface service does not block other endpoints of the interface service.


Esteban

Offline

#6 2019-12-20 21:21:12

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

Re: Interfaced method syncronisation

sicShared does NOT lock anything.
Check https://synopse.info/files/html/Synopse … ml#TITL_92
There is just a single instance of the class implementing the interface, shared by all callers.
It is up to the code writer to make its methods thread-safe, e.g. using TSynLock in appropriate points of the server-side code.

If you have some very long process, use interface callbacks for server-side notifications to the client side.
Please see the https://synopse.info/files/html/Synopse … l#TITL_152 documentation that @macfly quoted about.

Offline

#7 2019-12-22 10:42:30

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Re: Interfaced method syncronisation

Thank you for replies.

Indeed sicShared only has one instance and does not lock anything.

-- If you have some very long process
It's not so much about long process, here's situation where's a device that must have serialized access (which happen a lot in real life)
and mwthods need to be serialized (wait in que from multiple sources). So we need some kind of control: number of calls in que, timeouts, priorities...


Maybe isn't crazy idea to implement some kind of serialization of per method calls.
It's already impelented with SyncWithMainThread actually (what we use in production succesfully for several years smile)
that was done gratiously by ab.


Regards, Vojko

Offline

Board footer

Powered by FluxBB