Hi all.
Indy 10.
I used TIdUDPClient.SendBuffer in thread in general VCL manner as
non-thread safe (via Synchronize).
Now I need to post from thread immediately. Is TIdUDPClient.SendBuffer
thread safe (if I don't change properties of course)?
--
Alex
"Alex Belo" wrote in message
news:392691@forums.embarcadero.com...
> I used TIdUDPClient.SendBuffer in thread in general
> VCL manner as non-thread safe (via Synchronize).
>
> Now I need to post from thread immediately. Is
> TIdUDPClient.SendBuffer thread safe (if I don't
> change properties of course)?
Are you using the TIdUDPClient object in multiple threads? SendBuffer()
accesses the Binding property internally. Although sending data does not
need to be synchronized, the Binding property getter, which allocates the
socket, is not thread-safe. At the very least, if you activate the
TIdUDPClient (set its Active property to True, which allocates the Binding)
before any threads access it, then you should be ok.
--
Remy Lebeau (TeamB)
Hi Remy.
Thank you for answering.
Remy Lebeau (TeamB) wrote:
> > I used TIdUDPClient.SendBuffer in thread in general
> > VCL manner as non-thread safe (via Synchronize).
> >
> > Now I need to post from thread immediately. Is
> > TIdUDPClient.SendBuffer thread safe (if I don't
> > change properties of course)?
>
> Are you using the TIdUDPClient object in multiple threads?
No in fact. All TIdUDPClient properies/methods are used in Synchronize.
> SendBuffer() accesses the Binding property internally. Although
> sending data does not need to be synchronized, the Binding property
> getter, which allocates the socket, is not thread-safe. At the very
> least, if you activate the TIdUDPClient (set its Active property to
> True, which allocates the Binding)
I set Active=True at design time.
> before any threads access it, then you should be ok.
Many thanks for information, it will be useful in future (because I've
rethought my design and need not avoid call of Synchronize now).
Are such details documented? I mean that sending from different threads
is usual task, so (despite the fact that Indy is VCL-style library)
Indy components should support it at least in some low level methods on
some conditions (like Active=True in our case).
--
Alex
"Alex Belo" wrote in message
news:392879@forums.embarcadero.com...
> Are such details documented?
Not specifically, no. Indy is designed for threading, that is part of its
core design, but that does not mean you can throw away thread safety
altogether.
--
Remy Lebeau (TeamB)
Remy Lebeau (TeamB) wrote:
> > Are such details documented?
>
> Not specifically, no. Indy is designed for threading, that is part
> of its core design, but that does not mean you can throw away thread
> safety altogether.
No, I don't intend throw away thread safety altogether. :)
I'm just saying that it would be nice to document what methods and
under what conditions are thread-safe (like: "TIdUDPClient.SendBuffer
is thread-safe if Active=true before any threads access it"). IMHO this
information is important for everyone.
--
Alex