Re: Multitasking and containers
- From: Matthew Heaney <matthewjheaney@xxxxxxxxxxxxx>
- Date: Fri, 24 Nov 2006 12:12:13 GMT
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.
.
- References:
- Multitasking and containers
- From: Maciej Sobczak
- Re: Multitasking and containers
- From: Dmitry A. Kazakov
- Re: Multitasking and containers
- From: Maciej Sobczak
- Multitasking and containers
- Prev by Date: Re: Multitasking and containers
- Next by Date: Re: Multitasking and containers
- Previous by thread: Re: Multitasking and containers
- Next by thread: Re: Multitasking and containers
- Index(es):
Relevant Pages
|