Re: Multitasking and containers



Maciej Sobczak <no.spam@xxxxxxxxxxx> writes:

That would be interesting, but would break apart when encapsulated within a
protected object, because there multiple readers would be allowed.

But I think that's true only when multiple readers are calling protected
functions. (There is a subtle difference in semantics between protected
functions and protected procedures.) It does seem you'd need to use a
protected procedure when manipulating a container nested inside a protected
object, since a protected function wouldn't provide the level of
synchronization required.


Having a mutex for readers sounds like a concurrency killer and relying on
protected wrappers seems to be fragile because of this possible
mutability. So - what is The Solution (tm) for multiple tasks reading from
the same container?

Declare the container object inside a protected object, and use protected
procedures to manipulate the container. Protected wrappers should be fine, as
long as you use protected procedures, not protected functions.


Let's say you want to have N worker tasks consulting a shared dictionary
(map) that was initialized before the tasks started their work. How would you
solve this?

As above: declare the container object inside a protected object, and use
protected procedures to manipulate the container.
.



Relevant Pages

  • Re: GNAT for MS Visual Studio
    ... Consider a container inside the protected object. ... presumably has access variables to actual contained objects (to ... If the target objects are considered to be OUTside of the protected ...
    (comp.lang.ada)
  • Re: Multitasking and containers
    ... from concurrent tasks as long as the parameters do not overlap. ... protected "by using the normal techniques such as protected objects". ... But reading from the protected object is not mutually exclusive (many ... I think he didn't mean container being a protected object. ...
    (comp.lang.ada)
  • Re: Multitasking and containers
    ... John Barnes suggests that in order to read from the same container, the operations need to be protected "by using the normal techniques such as protected objects". ... But reading from the protected object is not mutually exclusive - so where's the gain? ... What's the difference between concurrent reads of, say, a Vector via protected object vs. direct access? ... That would be interesting, but would break apart when encapsulated within a protected object, because there multiple readers would be allowed. ...
    (comp.lang.ada)
  • Re: Multitasking and containers
    ... But reading from the protected object is not mutually exclusive (many ... between concurrent reads of, say, a Vector via protected object vs. ... I think he didn't mean container being a protected object. ... The cache shared between ...
    (comp.lang.ada)

Quantcast