Proposed C++ extension
Nathan Sidwell
nathan@codesourcery.com
Sat Aug 31 07:09:00 GMT 2002
Niall Douglas wrote:
> Why? Because C++ doesn't support multithreading very well. I have a
> number of implicitly shared classes for which I had to disable
> implicit sharing because of the potential of data corruption as it's
> impossible to synchronise all users of the implicit data without
> running through a mutex each time.
>
> Unfortunately disabling implicit sharing creates performance problems
> in something like a string class. If we had a special copy
> constructor for temporary objects, we could do ptr copies for the
> temporary objects and the real copy constructor for the final object.
> Obviously, optimisation can decide when user created local objects
> are unnecessary, and hence optimise them into temporary land.
can't what you want be done with,
class unique_t { ... };
class shared_t : public unique_t {... locks in here };
void somefunc (unique_t arg);
now a unique_t copy ctor is invoked.
your problem description is too vague. I can't tell if you want a magic
bullet which will make your program multithreadable, or if you want some way
of saying 'this is a unique object, no need to lock it'.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
More information about the Gcc
mailing list