Hi
all,
I am getting
following error in boost multi-index library. I am using following code to add
and remove procedures by id
in multi index
container. Can somebody please let me know what might be wrong here?
Really appreciate your quick
response on
this.
// HEADER
FILE
#include
<boost/multi_index_container.hpp>
#include
<boost/multi_index/member.hpp>
#include
<boost/multi_index/ordered_index.hpp>
#include
<boost/multi_index/hashed_index.hpp>
#include
<boost/config.hpp>
#include <boost/utility.hpp>
#include
<boost/shared_ptr.hpp>
#include
<boost/multi_index/key_extractors.hpp>
#include "Procedure.h"
using
boost::multi_index_container;
using namespace
boost::multi_index;
/**
*
Defines tag used for procedure id.
*/
struct procedure_id_tag
{
};
class
Procedure_Pool: boost::noncopyable {
private:
/**
* Type definition for
multi index container.
*/
typedef
multi_index_container<
Procedure*,
indexed_by<
hashed_unique<
tag<procedure_id_tag>,
const_mem_fun<Procedure, int, &Procedure::id>
>
>
> Procedure_Hashed_Pool;
/**
* Type definition for indexing based on procedure id tag.
*/
typedef Procedure_Hashed_Pool::index<procedure_id_tag>::type
Procedure_By_Id;
public:
/**
* Constructor.
*/
Procedure_Pool(): pool_(),
procedure_by_id_(pool_.get<procedure_id_tag>())
{
}
/**
* Adds specified procedure in this
pool.
* It will intenally used procedures id() method to index
procedure.
* @param _procedure Procedure to be added in this
pool
* @return Success (0) or Failure (-1) based on addition happened
or not
*/
int add_by_id(Procedure *
_procedure);
/**
* Removes procedure from this
pool.
* @param _procedure procedure that needs to be removed
* @return Success (0) or Failure (1) based on removal happend or not
*/
int remove_by_id(Procedure * _procedure);
/**
*
Retrieves procedure based on specified id.
* @param _id
Identifier
* @return Procedure Pointer to procedure. Returns 0 if
procedure not found
*/
Procedure * find_by_id(int
_id);
private:
/**
* Returns true if
procedure is present otherwise returns false.
* @param _procedure
procedure that needs to found
* @return true if found or false if not
found
*/
bool find_by_id(Procedure *
_procedure);
/**
* boost multiindex object that is associated
with this pool.
*/
Procedure_Hashed_Pool
pool_;
/**
* Refernece of pool that is indexed by procedure
id tag.
*/
Procedure_By_Id
&procedure_by_id_;
};
//
IMPLEMENTATION
#include
"../include/Procedure_Pool.h"
int
Procedure_Pool::add_by_id(Procedure *
_procedure)
{
LD_TRACE("Procedure_Pool::add_by_id");
ACE_ASSERT(_procedure
!= 0);
if (!find_by_id(_procedure)) {
// procedure not
found
procedure_by_id_.insert(_procedure);
//
debug info
ACE_DEBUG((LM_DEBUG, "Added procedure : %d \n",
_procedure->id()));
// return success
return
0;
} else {
// error
ACE_ERROR((LD_ERROR
"%N:%l Error in adding procedure : %d \n",
_procedure->id()));
// return failure
return
-1;
}
}
int
Procedure_Pool::remove_by_id(Procedure *
_procedure)
{
LD_TRACE("Procedure_Pool::remove_by_id");
ACE_ASSERT(_procedure
!= 0);
if (find_by_id(_procedure)) {
// procedure
found
procedure_by_id_.erase(_procedure->id());
ACE_DEBUG((LM_DEBUG,
"Removed procedure : %d \n", _procedure->id()));
return
0;
} else {
ACE_ERROR((LD_ERROR "%N:%l Error in removing
procedure : %d \n", _procedure->id()));
return
-1;
}
}
Procedure *
Procedure_Pool::find_by_id(int
_id)
{
LD_TRACE("Procedure_Pool::find_by_id");
Procedure_By_Id::iterator
it = procedure_by_id_.find(_id);
if (it != procedure_by_id_.end())
{
ACE_DEBUG((LM_DEBUG, "%N:%l Found procedure for id: %d \n",
_id));
return *it;
}
ACE_ERROR((LD_ERROR "%N:%l
Not able to found procedure for id: %d \n", _id));
// return
null
return 0;
}
bool
Procedure_Pool::find_by_id(Procedure *
_procedure)
{
LD_TRACE("Procedure_Pool::find_by_id");
ACE_ASSERT(_procedure
!= 0);
Procedure_By_Id::iterator it =
procedure_by_id_.find(_procedure->id());
return (it !=
procedure_by_id_.end());
}
// CORE STACK
TRACE
(gdb) where
#0 0x00000000 in ??
()
#1 0x000d0008 in
_ZNK5boost11multi_index13const_mem_funI9ProcedureiXadsrS2_NKS2_2idEvEEclERKS2_
()
#2 0x000cffa4 in
_ZNK5boost11multi_index13const_mem_funI9ProcedureiXadsrS2_NKS2_2idEvEEclIPS2_EEiRKT_
()
#3 0x000cf4dc in
_ZN5boost11multi_index6detail12hashed_indexINS0_13const_mem_funI9ProcedureiXadsrS4_NKS4_2idEvEEENS_4hashIiEESt8equal_toIiENS1_9nth_layerILi1EPS4_NS0_10indexed_byINS0_13hashed_uniqueINS0_3tagI16procedure_id_tagN4mpl_2naESH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_EES5_SH_SH_EESH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_SH_EESaISB_EEENS_3mpl6v_itemISF_NSN_7vector0ISH_EELi0EEENS1_17hashed_unique_tagEE5eraseEi
()
#4 0x00066774 in Procedure_Pool::remove_by_id ()
#5
0x0007a4ac in AP_TCP_Connection::unsubscribe ()
#6 0x0006bd5c in
Access_Point::unsubscribe ()
#7 0x00082988 in Sample_Procedure::handle
()
#8 0x0007a89c in AP_TCP_Connection::handle ()
#9 0x0005f380
in Tcp_Handler::handle_output ()
#10 0xff257ca8 in
ACE_Select_Reactor_Notify::dispatch_notify ()
at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#11 0xff26f424
in ACE_TP_Reactor::handle_notify_events () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#12 0xff26f188
in ACE_TP_Reactor::dispatch_i () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#13 0xff26eff8
in ACE_TP_Reactor::handle_events () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#14 0xff254e0c
in ACE_Reactor::run_reactor_event_loop () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#15 0x000f3848
in ACE_Reactor::run_event_loop ()
#16 0x000f37d8 in Global_Reactor::svc
()
#17 0xff2668dc in ACE_Task_Base::svc_run () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#18 0xff266cb0
in ACE_Thread_Adapter::invoke_i () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#19 0xff266c1c
in ACE_Thread_Adapter::invoke () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#20 0xff216d50
in ace_thread_adapter () at
/mot/proj/ivtools/ppatel1/ACE_wrappers/ace/String_Base.inl:32
#21 0xfe8db730
in _thread_start () from /usr/lib/libthread.so.1
#22 0xfe8db730 in
_thread_start () from /usr/lib/libthread.so.1