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
3c873350
Commit
3c873350
authored
Jan 22, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use type tags instead of typeid for attachables
parent
f6762dfc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
15 deletions
+28
-15
libcaf_core/caf/abstract_actor.hpp
libcaf_core/caf/abstract_actor.hpp
+0
-5
libcaf_core/caf/abstract_group.hpp
libcaf_core/caf/abstract_group.hpp
+1
-0
libcaf_core/caf/attachable.hpp
libcaf_core/caf/attachable.hpp
+20
-5
libcaf_core/caf/default_attachable.hpp
libcaf_core/caf/default_attachable.hpp
+1
-0
libcaf_core/caf/detail/functor_attachable.hpp
libcaf_core/caf/detail/functor_attachable.hpp
+1
-0
libcaf_core/src/abstract_group.cpp
libcaf_core/src/abstract_group.cpp
+1
-1
libcaf_core/src/attachable.cpp
libcaf_core/src/attachable.cpp
+2
-2
libcaf_core/src/default_attachable.cpp
libcaf_core/src/default_attachable.cpp
+1
-1
libcaf_core/src/local_actor.cpp
libcaf_core/src/local_actor.cpp
+1
-1
No files found.
libcaf_core/caf/abstract_actor.hpp
View file @
3c873350
...
@@ -100,11 +100,6 @@ class abstract_actor : public abstract_channel {
...
@@ -100,11 +100,6 @@ class abstract_actor : public abstract_channel {
*/
*/
size_t
detach
(
const
attachable
::
token
&
what
);
size_t
detach
(
const
attachable
::
token
&
what
);
template
<
class
T
>
size_t
detach
(
const
T
&
what
)
{
return
detach
(
attachable
::
token
{
typeid
(
T
),
&
what
});
}
enum
linking_operation
{
enum
linking_operation
{
establish_link_op
,
establish_link_op
,
establish_backlink_op
,
establish_backlink_op
,
...
...
libcaf_core/caf/abstract_group.hpp
View file @
3c873350
...
@@ -59,6 +59,7 @@ class abstract_group : public abstract_channel {
...
@@ -59,6 +59,7 @@ class abstract_group : public abstract_channel {
struct
subscription_token
{
struct
subscription_token
{
intrusive_ptr
<
abstract_group
>
group
;
intrusive_ptr
<
abstract_group
>
group
;
static
constexpr
size_t
token_type
=
attachable
::
token
::
subscription
;
};
};
class
subscription_predicate
{
class
subscription_predicate
{
...
...
libcaf_core/caf/attachable.hpp
View file @
3c873350
...
@@ -41,25 +41,40 @@ class attachable {
...
@@ -41,25 +41,40 @@ class attachable {
attachable
&
operator
=
(
const
attachable
&
)
=
delete
;
attachable
&
operator
=
(
const
attachable
&
)
=
delete
;
/**
/**
* Represents a pointer to a value with its
RTTI
.
* Represents a pointer to a value with its
subtype as type ID number
.
*/
*/
struct
token
{
struct
token
{
/**
* Identifies a non-matchable subtype.
*/
static
constexpr
size_t
anonymous
=
0
;
/**
* Identifies `abstract_group::subscription`.
*/
static
constexpr
size_t
subscription
=
1
;
/**
* Identifies `default_attachable::observe_token`.
*/
static
constexpr
size_t
observer
=
2
;
template
<
class
T
>
template
<
class
T
>
token
(
const
T
&
tk
)
:
subtype
(
typeid
(
T
)
),
ptr
(
&
tk
)
{
token
(
const
T
&
tk
)
:
subtype
(
T
::
token_type
),
ptr
(
&
tk
)
{
// nop
// nop
}
}
/**
/**
* Denotes the type of ptr.
* Denotes the type of ptr.
*/
*/
const
std
::
type_info
&
subtype
;
size_t
subtype
;
/**
/**
* Any value, used to identify attachable instances.
* Any value, used to identify attachable instances.
*/
*/
const
void
*
ptr
;
const
void
*
ptr
;
token
(
const
std
::
type_info
&
subtype
,
const
void
*
ptr
);
token
(
size_t
subtype
,
const
void
*
ptr
);
};
};
virtual
~
attachable
();
virtual
~
attachable
();
...
@@ -89,7 +104,7 @@ class attachable {
...
@@ -89,7 +104,7 @@ class attachable {
*/
*/
template
<
class
T
>
template
<
class
T
>
bool
matches
(
const
T
&
what
)
{
bool
matches
(
const
T
&
what
)
{
return
matches
(
token
{
typeid
(
T
)
,
&
what
});
return
matches
(
token
{
T
::
token_type
,
&
what
});
}
}
std
::
unique_ptr
<
attachable
>
next
;
std
::
unique_ptr
<
attachable
>
next
;
...
...
libcaf_core/caf/default_attachable.hpp
View file @
3c873350
...
@@ -35,6 +35,7 @@ class default_attachable : public attachable {
...
@@ -35,6 +35,7 @@ class default_attachable : public attachable {
struct
observe_token
{
struct
observe_token
{
actor_addr
observer
;
actor_addr
observer
;
observe_type
type
;
observe_type
type
;
static
constexpr
size_t
token_type
=
attachable
::
token
::
observer
;
};
};
void
actor_exited
(
abstract_actor
*
self
,
uint32_t
reason
)
override
;
void
actor_exited
(
abstract_actor
*
self
,
uint32_t
reason
)
override
;
...
...
libcaf_core/caf/detail/functor_attachable.hpp
View file @
3c873350
...
@@ -39,6 +39,7 @@ struct functor_attachable : attachable {
...
@@ -39,6 +39,7 @@ struct functor_attachable : attachable {
void
actor_exited
(
abstract_actor
*
self
,
uint32_t
reason
)
override
{
void
actor_exited
(
abstract_actor
*
self
,
uint32_t
reason
)
override
{
m_functor
(
self
,
reason
);
m_functor
(
self
,
reason
);
}
}
static
constexpr
size_t
token_type
=
attachable
::
token
::
anonymous
;
};
};
template
<
class
F
>
template
<
class
F
>
...
...
libcaf_core/src/abstract_group.cpp
View file @
3c873350
...
@@ -37,7 +37,7 @@ void abstract_group::subscription::actor_exited(abstract_actor* ptr, uint32_t) {
...
@@ -37,7 +37,7 @@ void abstract_group::subscription::actor_exited(abstract_actor* ptr, uint32_t) {
}
}
bool
abstract_group
::
subscription
::
matches
(
const
token
&
what
)
{
bool
abstract_group
::
subscription
::
matches
(
const
token
&
what
)
{
if
(
what
.
subtype
!=
typeid
(
subscription_token
)
)
{
if
(
what
.
subtype
!=
attachable
::
token
::
subscription
)
{
return
false
;
return
false
;
}
}
auto
&
ot
=
*
reinterpret_cast
<
const
subscription_token
*>
(
what
.
ptr
);
auto
&
ot
=
*
reinterpret_cast
<
const
subscription_token
*>
(
what
.
ptr
);
...
...
libcaf_core/src/attachable.cpp
View file @
3c873350
...
@@ -25,8 +25,8 @@ attachable::~attachable() {
...
@@ -25,8 +25,8 @@ attachable::~attachable() {
// nop
// nop
}
}
attachable
::
token
::
token
(
const
std
::
type_info
&
tinfo
,
const
void
*
vptr
)
attachable
::
token
::
token
(
size_t
typenr
,
const
void
*
vptr
)
:
subtype
(
t
info
),
ptr
(
vptr
)
{
:
subtype
(
t
ypenr
),
ptr
(
vptr
)
{
// nop
// nop
}
}
...
...
libcaf_core/src/default_attachable.cpp
View file @
3c873350
...
@@ -44,7 +44,7 @@ void default_attachable::actor_exited(abstract_actor* self, uint32_t reason) {
...
@@ -44,7 +44,7 @@ void default_attachable::actor_exited(abstract_actor* self, uint32_t reason) {
}
}
bool
default_attachable
::
matches
(
const
token
&
what
)
{
bool
default_attachable
::
matches
(
const
token
&
what
)
{
if
(
what
.
subtype
!=
typeid
(
observe_token
)
)
{
if
(
what
.
subtype
!=
attachable
::
token
::
observer
)
{
return
false
;
return
false
;
}
}
auto
&
ot
=
*
reinterpret_cast
<
const
observe_token
*>
(
what
.
ptr
);
auto
&
ot
=
*
reinterpret_cast
<
const
observe_token
*>
(
what
.
ptr
);
...
...
libcaf_core/src/local_actor.cpp
View file @
3c873350
...
@@ -57,7 +57,7 @@ void local_actor::demonitor(const actor_addr& whom) {
...
@@ -57,7 +57,7 @@ void local_actor::demonitor(const actor_addr& whom) {
}
}
auto
ptr
=
actor_cast
<
abstract_actor_ptr
>
(
whom
);
auto
ptr
=
actor_cast
<
abstract_actor_ptr
>
(
whom
);
default_attachable
::
observe_token
tk
{
address
(),
default_attachable
::
monitor
};
default_attachable
::
observe_token
tk
{
address
(),
default_attachable
::
monitor
};
ptr
->
detach
(
{
typeid
(
default_attachable
::
observe_token
),
&
tk
}
);
ptr
->
detach
(
tk
);
}
}
void
local_actor
::
join
(
const
group
&
what
)
{
void
local_actor
::
join
(
const
group
&
what
)
{
...
...
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