Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ACE_DLList and the remove () method

61 views
Skip to first unread message

Ramesh Kumar

unread,
Jan 1, 2006, 6:19:36 AM1/1/06
to
ACE VERSION: 5.4

HOST MACHINE and OPERATING SYSTEM:
Intel X86 - SuSE Linux 9.1

TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
COMPILER NAME AND VERSION (AND PATCHLEVEL):
GNU Compiler (gcc-c++-3.3.3-41)

CONTENTS OF $ACE_ROOT/ace/config.h: N/A

CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU (unless
this isn't used in this case, e.g., with Microsoft Visual C++): N/A

AREA/CLASS/EXAMPLE AFFECTED:
N/A

DOES THE PROBLEM AFFECT:
COMPILATION?
LINKING?
On Unix systems, did you run make realclean first?
EXECUTION?
OTHER (please specify)?
N/A

SYNOPSIS: ACE_DLList<T>::remove (ACE_DLList_Node *)

DESCRIPTION:
Dear folks,
I have two threads namely, Thread A & B, a list & an array.

I have the following requirement:
Each new element/node in the list will be inserted at the tail end (by
Thread A). At the time of insertion, the address of the new node in the
list would be noted in a separate, indexed table/array. Thread B, using
addresses of nodes from this array/table, will be able to remove any
node off of the list in a constant time (not having to run through
every nodes before arriving to the one desired). Please assume all
synchronisation to access the list has been taken care of.

My question is:
What kind of container do I use for this purpose ? The closest one I
could think of is the ACE_DLList. However, I am having a bit of a
problem, getting the address of a new node inserted and then using it
to delete the node later in the way described above. The method,
ACE_DLList<T>::remove (ACE_DLList_Node *) seems to be quite puzzling to
me. I think this method would work, but how do I get the ACE_DLList
Node's pointer value in the first place to be passed to the method, for
there is no method to obtain this within the template class
ACE_DLList<T> ?

Your help would be greatly appreciated. Thank you.

Ramesh

REPEAT BY:
N/A

SAMPLE FIX/WORKAROUND:
N/A

Douglas C. Schmidt

unread,
Jan 1, 2006, 11:40:22 AM1/1/06
to
Hi Ramesh,

Thanks for using the PRF.

The ACE_DLList<> class is VERY weird (I didn't write it, and would
never have come up with something so convoluted...). As far as I can
tell, the way that you can get an ACE_DLList_Node * is either by using

. The operator *() or not_done() (etc.) methods of
ACE_Double_Linked_List_Iterator_Base<>, which is curiously inherited
publically by the ACE_DLList_Iterator<> class, so you can access these
methods or

. Via the get() method on ACE_Double_Linked_List<>, which is also
curiously inherited publically by ACE_DLList<>.

Please take a close look at the code and you'll see that by
instantiating these classes with ACE_DLList_Node and then using them
as the base class for the ACE_DLList_Iterator<> and ACE_DLList<>
classes it's possible to access the contents as either type "T" or
type "ACE_DLList_Node".

Yes, I agree this is totally confusing, but it might work to solve
your needs.

Take care,

Doug


--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Institute for Software Integrated Systems WEB: www.dre.vanderbilt.edu/~schmidt
Vanderbilt University, Nashville TN, 37203 NET: d.sc...@vanderbilt.edu

0 new messages