00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "assa/Logger.h"
00014 #include "assa/IdSet.h"
00015
00016 using namespace ASSA;
00017
00018 int
00019 IdSet::
00020 newid()
00021 {
00022 register int i;
00023 register int current;
00024
00025 trace("IdSet::newid");
00026
00027 current = m_next_available_id++;
00028
00029 if (m_next_available_id < FD_SETSIZE)
00030 {
00031
00032 FD_SET(current, &m_id_set_map);
00033
00034
00035
00036
00037
00038 for (i=current+1; i<FD_SETSIZE; i++)
00039 {
00040 if (!FD_ISSET(i, &m_id_set_map))
00041 {
00042 m_next_available_id = i;
00043 return current;
00044 }
00045 }
00046
00047 m_next_available_id = FD_SETSIZE;
00048 }
00049 return -1;
00050 }
00051
00052 int
00053 IdSet::
00054 recycle(int id_)
00055 {
00056 trace("IdSet::recycle");
00057
00058 if ( 0 <= id_ && id_ < FD_SETSIZE ) {
00059 FD_CLR(id_, &m_id_set_map);
00060
00061
00062 if (id_ < m_next_available_id) {
00063 m_next_available_id = id_;
00064 }
00065 return 0;
00066 }
00067 return -1;
00068 }