This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Diff mt_allocator.h part 1 of item 3
- From: Stefan Olsson <stefan at xapa dot se>
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 15 Jan 2004 11:39:30 +0100
- Subject: Diff mt_allocator.h part 1 of item 3
Hi,
here's the first part of the patch that addresses item 3 in the rfc -
the one that will reuse thread id's as soon as possible by changing the
behaviour of thread_freelist to do "push_front" when threads die instead
of "push_back". I know that it seems like a lot of patches, but I really
want to make sure that everyone sees what is being altered.
At the same time - after some reading up - we have added keyword
volatile to the global vars affected by this patch and if no-one has an
other opinion, we will do this where it makes sense on other global vars
(such as the freelists etc) as well.
Brgds
/Stefan
125c125
< static bool _S_initialized;
---
> static bool volatile _S_initialized;
154c154
< * is called, we return the thread id to the back of this list.
---
> * is called, we return the thread id to the front of this list.
162c162
< thread_record* next;
---
> thread_record* volatile next;
170,171c170
< static thread_record* _S_thread_freelist_first;
< static thread_record* _S_thread_freelist_last;
---
> static thread_record* volatile _S_thread_freelist_first;
415c414
< }
---
> }
602c601
< * Set last record and pointer to this
---
> * Set last record
606d604
< _S_thread_freelist_last = &_S_thread_freelist_first[i - 1];
711c709
< * Return this thread id record to thread_freelist
---
> * Return this thread id record to front of thread_freelist
714,716c712,713
< _S_thread_freelist_last->next = (thread_record*)freelist_pos;
< _S_thread_freelist_last = (thread_record*)freelist_pos;
< _S_thread_freelist_last->next = NULL;
---
> ((thread_record*)freelist_pos)->next = _S_thread_freelist_first;
> _S_thread_freelist_first = (thread_record*)freelist_pos;
733c730
< thread_record* freelist_pos;
---
> thread_record* volatile freelist_pos;
781c778
< __mt_alloc<_Tp>::_S_initialized = false;
---
> volatile __mt_alloc<_Tp>::_S_initialized = false;
832,835c829
< __mt_alloc<_Tp>::_S_thread_freelist_first = NULL;
<
< template<typename _Tp> typename __mt_alloc<_Tp>::thread_record*
< __mt_alloc<_Tp>::_S_thread_freelist_last = NULL;
---
> volatile __mt_alloc<_Tp>::_S_thread_freelist_first = NULL;