Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
91bf40c1
Commit
91bf40c1
authored
19 years ago
by
jpbl
Browse files
Options
Downloads
Patches
Plain Diff
added missing files
parent
28d8251c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utilspp/singleton/lifetime_with_longevity.inl
+68
-0
68 additions, 0 deletions
utilspp/singleton/lifetime_with_longevity.inl
with
68 additions
and
0 deletions
utilspp/singleton/lifetime_with_longevity.inl
0 → 100644
+
68
−
0
View file @
91bf40c1
#include <algorithm>
#include <stdexcept>
template< typename T, typename T_destroyer >
void
utilspp::set_longevity( T *obj, unsigned int longevity, T_destroyer d )
{
using namespace utilspp::private_members;
tracker_array new_array = static_cast< tracker_array >(
std::realloc(
m_tracker_array,
m_nb_elements + 1
)
);
if( new_array == NULL )
{
throw std::bad_alloc();
}
lifetime_tracker *p = new concrete_lifetime_tracker< T, T_destroyer >(
obj,
longevity,
d
);
m_tracker_array = new_array;
tracker_array pos = std::upper_bound(
m_tracker_array,
m_tracker_array + m_nb_elements,
p,
&lifetime_tracker::compare
);
std::copy_backward(
pos,
m_tracker_array + m_nb_elements,
m_tracker_array + m_nb_elements + 1
);
*pos = p;
m_nb_elements++;
std::atexit( &at_exit_func );
};
template< typename T >
void
utilspp::lifetime_with_longevity< T >::schedule_destruction( T *obj, void (*func)() )
{
utilspp::private_members::adapter<T> adapter = { func };
utilspp::set_longevity( obj, get_longevity( obj ), adapter );
}
template< typename T >
void
utilspp::lifetime_with_longevity< T >::on_dead_reference()
{
throw std::logic_error("Dead reference detected");
}
template< typename T >
unsigned int
utilspp::get_longevity( T * )
{
return 1000;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment