felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven E. Harris" <...@panix.com>
Subject Confusion about concurrency in ServiceListener/ServiceTracker callbacks
Date Fri, 16 Feb 2007 18:14:21 GMT
I'm confused as to whether a ServiceListener can be called on from
multiple threads by the OSGi framework, say, if two service-related
events occurred "at the same" time by different threads registering
and unregistering services.

The question extends to ServiceTracker and its
ServiceTrackerCustomizer: Can the addingService(), modifiedService(),
and removedService() methods be called on concurrently, meaning that
their operation must be made thread-aware?

Section 6.1.21 of the OSGi R4 core specification reads:

,----
| When a ServiceEvent is fired, it is synchronously delivered to a
| BundleListener.
`----

Aside from it looking like "BundleListener" should probably be
"ServiceListener", the sentence sounds like it's saying that only one
ServiceEvent will be delivered to a ServiceListener at a time. Is that
true?

If so, can I also conclude that a ServiceTrackerCustomizer will only
be called on by one thread at a time? I ask because the
ServiceTrackerCustomizer implementation has some synchronized blocks
that are attempting to protect some of its data against concurrent
access, but the user-provided callback functions are called on outside
of those synchronized regions.

-- 
Steven E. Harris

Mime
View raw message