This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Proposed C++ extension
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Niall Douglas <ned at nedprod dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 31 Aug 2002 15:09:01 +0100
- Subject: Re: Proposed C++ extension
- Organization: Codesourcery LLC
- References: <3D701B78.8275.2A4BC906@localhost>
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