Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
fbba3248
Commit
fbba3248
authored
Jan 20, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #410 from Lingxi-Li/topic/intrusive_ptr
Improve `intrusive_ptr`
parents
0b167399
b95cc31e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
24 deletions
+4
-24
libcaf_core/caf/intrusive_ptr.hpp
libcaf_core/caf/intrusive_ptr.hpp
+4
-24
No files found.
libcaf_core/caf/intrusive_ptr.hpp
View file @
fbba3248
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
namespace
caf
{
namespace
caf
{
/// An intrusive, reference counting smart pointer imp
e
lementation.
/// An intrusive, reference counting smart pointer implementation.
/// @relates ref_counted
/// @relates ref_counted
template
<
class
T
>
template
<
class
T
>
class
intrusive_ptr
:
detail
::
comparable
<
intrusive_ptr
<
T
>>
,
class
intrusive_ptr
:
detail
::
comparable
<
intrusive_ptr
<
T
>>
,
...
@@ -66,9 +66,8 @@ public:
...
@@ -66,9 +66,8 @@ public:
}
}
~
intrusive_ptr
()
{
~
intrusive_ptr
()
{
if
(
ptr_
)
{
if
(
ptr_
)
intrusive_ptr_release
(
ptr_
);
intrusive_ptr_release
(
ptr_
);
}
}
}
void
swap
(
intrusive_ptr
&
other
)
noexcept
{
void
swap
(
intrusive_ptr
&
other
)
noexcept
{
...
@@ -92,14 +91,8 @@ public:
...
@@ -92,14 +91,8 @@ public:
void
reset
(
pointer
new_value
=
nullptr
,
bool
add_ref
=
true
)
{
void
reset
(
pointer
new_value
=
nullptr
,
bool
add_ref
=
true
)
{
auto
old
=
ptr_
;
auto
old
=
ptr_
;
set_ptr
(
new_value
,
add_ref
);
set_ptr
(
new_value
,
add_ref
);
if
(
old
)
{
if
(
old
)
intrusive_ptr_release
(
old
);
intrusive_ptr_release
(
old
);
}
}
template
<
class
...
Ts
>
void
emplace
(
Ts
&&
...
xs
)
{
reset
(
new
T
(
std
::
forward
<
Ts
>
(
xs
)...));
}
}
intrusive_ptr
&
operator
=
(
pointer
ptr
)
{
intrusive_ptr
&
operator
=
(
pointer
ptr
)
{
...
@@ -107,24 +100,11 @@ public:
...
@@ -107,24 +100,11 @@ public:
return
*
this
;
return
*
this
;
}
}
intrusive_ptr
&
operator
=
(
intrusive_ptr
&&
other
)
{
intrusive_ptr
&
operator
=
(
intrusive_ptr
other
)
{
swap
(
other
);
swap
(
other
);
return
*
this
;
return
*
this
;
}
}
intrusive_ptr
&
operator
=
(
const
intrusive_ptr
&
other
)
{
intrusive_ptr
tmp
{
other
};
swap
(
tmp
);
return
*
this
;
}
template
<
class
Y
>
intrusive_ptr
&
operator
=
(
intrusive_ptr
<
Y
>
other
)
{
intrusive_ptr
tmp
{
std
::
move
(
other
)};
swap
(
tmp
);
return
*
this
;
}
pointer
get
()
const
{
pointer
get
()
const
{
return
ptr_
;
return
ptr_
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment