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
3d5ddb6e
Commit
3d5ddb6e
authored
Dec 14, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove legacy duration type (replaced by timespan)
parent
ea5b4f17
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
116 additions
and
410 deletions
+116
-410
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+0
-1
libcaf_core/caf/after.hpp
libcaf_core/caf/after.hpp
+6
-10
libcaf_core/caf/all.hpp
libcaf_core/caf/all.hpp
+0
-1
libcaf_core/caf/behavior.hpp
libcaf_core/caf/behavior.hpp
+2
-3
libcaf_core/caf/detail/behavior_impl.hpp
libcaf_core/caf/detail/behavior_impl.hpp
+5
-4
libcaf_core/caf/detail/blocking_behavior.hpp
libcaf_core/caf/detail/blocking_behavior.hpp
+3
-3
libcaf_core/caf/duration.hpp
libcaf_core/caf/duration.hpp
+0
-174
libcaf_core/caf/function_view.hpp
libcaf_core/caf/function_view.hpp
+20
-9
libcaf_core/caf/fwd.hpp
libcaf_core/caf/fwd.hpp
+0
-1
libcaf_core/caf/local_actor.hpp
libcaf_core/caf/local_actor.hpp
+2
-2
libcaf_core/caf/message_handler.hpp
libcaf_core/caf/message_handler.hpp
+0
-1
libcaf_core/caf/mixin/requester.hpp
libcaf_core/caf/mixin/requester.hpp
+8
-26
libcaf_core/caf/mixin/sender.hpp
libcaf_core/caf/mixin/sender.hpp
+0
-1
libcaf_core/caf/scheduler/abstract_coordinator.hpp
libcaf_core/caf/scheduler/abstract_coordinator.hpp
+0
-1
libcaf_core/caf/timeout_definition.hpp
libcaf_core/caf/timeout_definition.hpp
+5
-4
libcaf_core/caf/timespan.hpp
libcaf_core/caf/timespan.hpp
+5
-0
libcaf_core/caf/type_nr.hpp
libcaf_core/caf/type_nr.hpp
+0
-1
libcaf_core/caf/typed_behavior.hpp
libcaf_core/caf/typed_behavior.hpp
+1
-1
libcaf_core/caf/uniform_type_info_map.hpp
libcaf_core/caf/uniform_type_info_map.hpp
+0
-1
libcaf_core/src/blocking_actor.cpp
libcaf_core/src/blocking_actor.cpp
+5
-7
libcaf_core/src/detail/behavior_impl.cpp
libcaf_core/src/detail/behavior_impl.cpp
+6
-1
libcaf_core/src/detail/blocking_behavior.cpp
libcaf_core/src/detail/blocking_behavior.cpp
+2
-2
libcaf_core/src/duration.cpp
libcaf_core/src/duration.cpp
+0
-63
libcaf_core/src/local_actor.cpp
libcaf_core/src/local_actor.cpp
+4
-4
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+6
-6
libcaf_core/src/scheduler/abstract_coordinator.cpp
libcaf_core/src/scheduler/abstract_coordinator.cpp
+0
-1
libcaf_core/src/uniform_type_info_map.cpp
libcaf_core/src/uniform_type_info_map.cpp
+0
-2
libcaf_core/test/actor_clock.cpp
libcaf_core/test/actor_clock.cpp
+25
-30
libcaf_core/test/binary_deserializer.cpp
libcaf_core/test/binary_deserializer.cpp
+1
-15
libcaf_core/test/binary_serializer.cpp
libcaf_core/test/binary_serializer.cpp
+1
-15
libcaf_core/test/serialization.cpp
libcaf_core/test/serialization.cpp
+4
-7
libcaf_core/test/simple_timeout.cpp
libcaf_core/test/simple_timeout.cpp
+0
-8
libcaf_io/caf/io/middleman.hpp
libcaf_io/caf/io/middleman.hpp
+4
-4
libcaf_io/src/io/middleman.cpp
libcaf_io/src/io/middleman.cpp
+1
-1
No files found.
libcaf_core/CMakeLists.txt
View file @
3d5ddb6e
...
@@ -90,7 +90,6 @@ set(CAF_CORE_SOURCES
...
@@ -90,7 +90,6 @@ set(CAF_CORE_SOURCES
src/detail/uri_impl.cpp
src/detail/uri_impl.cpp
src/downstream_manager.cpp
src/downstream_manager.cpp
src/downstream_manager_base.cpp
src/downstream_manager_base.cpp
src/duration.cpp
src/error.cpp
src/error.cpp
src/event_based_actor.cpp
src/event_based_actor.cpp
src/execution_unit.cpp
src/execution_unit.cpp
...
...
libcaf_core/caf/after.hpp
View file @
3d5ddb6e
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#pragma once
#pragma once
#include <chrono>
#include <tuple>
#include <tuple>
#include <type_traits>
#include <type_traits>
...
@@ -28,7 +29,7 @@ namespace caf {
...
@@ -28,7 +29,7 @@ namespace caf {
class
CAF_CORE_EXPORT
timeout_definition_builder
{
class
CAF_CORE_EXPORT
timeout_definition_builder
{
public:
public:
constexpr
timeout_definition_builder
(
duratio
n
d
)
:
tout_
(
d
)
{
explicit
constexpr
timeout_definition_builder
(
timespa
n
d
)
:
tout_
(
d
)
{
// nop
// nop
}
}
...
@@ -38,19 +39,14 @@ public:
...
@@ -38,19 +39,14 @@ public:
}
}
private:
private:
duratio
n
tout_
;
timespa
n
tout_
;
};
};
/// Returns a generator for timeouts.
constexpr
timeout_definition_builder
after
(
duration
d
)
{
return
{
d
};
}
/// Returns a generator for timeouts.
/// Returns a generator for timeouts.
template
<
class
Rep
,
class
Period
>
template
<
class
Rep
,
class
Period
>
constexpr
timeout_definition_builder
constexpr
auto
after
(
std
::
chrono
::
duration
<
Rep
,
Period
>
d
)
{
after
(
std
::
chrono
::
duration
<
Rep
,
Period
>
d
)
{
using
std
::
chrono
::
duration_cast
;
return
after
(
duration
{
d
})
;
return
timeout_definition_builder
{
duration_cast
<
timespan
>
(
d
)}
;
}
}
}
// namespace caf
}
// namespace caf
libcaf_core/caf/all.hpp
View file @
3d5ddb6e
...
@@ -62,7 +62,6 @@
...
@@ -62,7 +62,6 @@
#include "caf/deserializer.hpp"
#include "caf/deserializer.hpp"
#include "caf/detail/config_value_adaptor_field_impl.hpp"
#include "caf/detail/config_value_adaptor_field_impl.hpp"
#include "caf/downstream_msg.hpp"
#include "caf/downstream_msg.hpp"
#include "caf/duration.hpp"
#include "caf/error.hpp"
#include "caf/error.hpp"
#include "caf/event_based_actor.hpp"
#include "caf/event_based_actor.hpp"
#include "caf/exec_main.hpp"
#include "caf/exec_main.hpp"
...
...
libcaf_core/caf/behavior.hpp
View file @
3d5ddb6e
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
#include "caf/detail/core_export.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/duration.hpp"
#include "caf/none.hpp"
#include "caf/none.hpp"
#include "caf/timeout_definition.hpp"
#include "caf/timeout_definition.hpp"
...
@@ -87,9 +86,9 @@ public:
...
@@ -87,9 +86,9 @@ public:
impl_
->
handle_timeout
();
impl_
->
handle_timeout
();
}
}
/// Returns the
duratio
n after which receive operations
/// Returns the
timespa
n after which receive operations
/// using this behavior should time out.
/// using this behavior should time out.
inline
const
duration
&
timeout
()
cons
t
{
timespan
timeout
()
const
noexcep
t
{
return
impl_
->
timeout
();
return
impl_
->
timeout
();
}
}
...
...
libcaf_core/caf/detail/behavior_impl.hpp
View file @
3d5ddb6e
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include "caf/detail/invoke_result_visitor.hpp"
#include "caf/detail/invoke_result_visitor.hpp"
#include "caf/detail/tail_argument_token.hpp"
#include "caf/detail/tail_argument_token.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/duration.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/make_counted.hpp"
#include "caf/make_counted.hpp"
#include "caf/match_case.hpp"
#include "caf/match_case.hpp"
...
@@ -56,7 +55,9 @@ public:
...
@@ -56,7 +55,9 @@ public:
~
behavior_impl
()
override
;
~
behavior_impl
()
override
;
behavior_impl
(
duration
tout
=
duration
{});
behavior_impl
();
explicit
behavior_impl
(
timespan
tout
);
virtual
match_case
::
result
invoke_empty
(
detail
::
invoke_result_visitor
&
f
);
virtual
match_case
::
result
invoke_empty
(
detail
::
invoke_result_visitor
&
f
);
...
@@ -71,14 +72,14 @@ public:
...
@@ -71,14 +72,14 @@ public:
virtual
void
handle_timeout
();
virtual
void
handle_timeout
();
inline
const
duration
&
timeout
()
cons
t
{
timespan
timeout
()
const
noexcep
t
{
return
timeout_
;
return
timeout_
;
}
}
pointer
or_else
(
const
pointer
&
other
);
pointer
or_else
(
const
pointer
&
other
);
protected:
protected:
duratio
n
timeout_
;
timespa
n
timeout_
;
match_case_info
*
begin_
;
match_case_info
*
begin_
;
match_case_info
*
end_
;
match_case_info
*
end_
;
};
};
...
...
libcaf_core/caf/detail/blocking_behavior.hpp
View file @
3d5ddb6e
...
@@ -36,7 +36,7 @@ public:
...
@@ -36,7 +36,7 @@ public:
virtual
result
<
message
>
fallback
(
message_view
&
);
virtual
result
<
message
>
fallback
(
message_view
&
);
virtual
duratio
n
timeout
();
virtual
timespa
n
timeout
();
virtual
void
handle_timeout
();
virtual
void
handle_timeout
();
};
};
...
@@ -70,7 +70,7 @@ public:
...
@@ -70,7 +70,7 @@ public:
blocking_behavior_v3
(
blocking_behavior_v3
&&
)
=
default
;
blocking_behavior_v3
(
blocking_behavior_v3
&&
)
=
default
;
duratio
n
timeout
()
override
{
timespa
n
timeout
()
override
{
return
f
.
timeout
;
return
f
.
timeout
;
}
}
...
@@ -96,7 +96,7 @@ public:
...
@@ -96,7 +96,7 @@ public:
return
f1
.
handler
(
x
);
return
f1
.
handler
(
x
);
}
}
duratio
n
timeout
()
override
{
timespa
n
timeout
()
override
{
return
f2
.
timeout
;
return
f2
.
timeout
;
}
}
...
...
libcaf_core/caf/duration.hpp
deleted
100644 → 0
View file @
ea5b4f17
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
#include <chrono>
#include <cstdint>
#include <stdexcept>
#include <string>
#include "caf/detail/core_export.hpp"
#include "caf/error.hpp"
namespace
caf
{
/// SI time units to specify timeouts.
/// @relates duration
enum
class
time_unit
:
uint32_t
{
invalid
,
minutes
,
seconds
,
milliseconds
,
microseconds
,
nanoseconds
};
/// Relates time_unit
CAF_CORE_EXPORT
std
::
string
to_string
(
time_unit
x
);
// Calculates the index of a time_unit from the denominator of a ratio.
constexpr
intmax_t
denom_to_unit_index
(
intmax_t
x
,
intmax_t
offset
=
2
)
{
return
x
<
1000
?
(
x
==
1
?
offset
:
0
)
:
denom_to_unit_index
(
x
/
1000
,
offset
+
1
);
}
constexpr
time_unit
denom_to_time_unit
(
intmax_t
x
)
{
return
static_cast
<
time_unit
>
(
denom_to_unit_index
(
x
));
}
/// Converts the ratio Num/Denom to a `time_unit` if the ratio describes
/// seconds, milliseconds, microseconds, or minutes. Minutes are mapped
/// to `time_unit::seconds`, any unrecognized ratio to `time_unit::invalid`.
/// @relates duration
template
<
intmax_t
Num
,
intmax_t
Denom
>
struct
ratio_to_time_unit_helper
;
template
<
intmax_t
Denom
>
struct
ratio_to_time_unit_helper
<
1
,
Denom
>
{
static
constexpr
time_unit
value
=
denom_to_time_unit
(
Denom
);
};
template
<
>
struct
ratio_to_time_unit_helper
<
60
,
1
>
{
static
constexpr
time_unit
value
=
time_unit
::
minutes
;
};
/// Converts an STL time period to a `time_unit`.
/// @relates duration
template
<
class
Period
>
constexpr
time_unit
get_time_unit_from_period
()
{
return
ratio_to_time_unit_helper
<
Period
::
num
,
Period
::
den
>::
value
;
}
/// Represents an infinite amount of timeout for specifying "invalid" timeouts.
struct
infinite_t
{
constexpr
infinite_t
()
{
// nop
}
};
static
constexpr
infinite_t
infinite
=
infinite_t
{};
/// Time duration consisting of a `time_unit` and a 64 bit unsigned integer.
class
CAF_CORE_EXPORT
duration
{
public:
constexpr
duration
()
:
unit
(
time_unit
::
invalid
),
count
(
0
)
{
// nop
}
constexpr
duration
(
time_unit
u
,
uint32_t
v
)
:
unit
(
u
),
count
(
v
)
{
// nop
}
constexpr
duration
(
infinite_t
)
:
unit
(
time_unit
::
invalid
),
count
(
0
)
{
// nop
}
/// Creates a new instance from an STL duration.
/// @throws std::invalid_argument Thrown if `d.count() is negative.
template
<
class
Rep
,
class
Period
,
class
E
=
typename
std
::
enable_if
<
std
::
is_integral
<
Rep
>
::
value
&&
get_time_unit_from_period
<
Period
>
()
!=
time_unit
::
invalid
>::
type
>
explicit
duration
(
const
std
::
chrono
::
duration
<
Rep
,
Period
>&
d
)
:
unit
(
get_time_unit_from_period
<
Period
>
()),
count
(
d
.
count
()
<
0
?
0u
:
static_cast
<
uint64_t
>
(
d
.
count
()))
{
// nop
}
/// Returns `unit != time_unit::invalid`.
constexpr
bool
valid
()
const
{
return
unit
!=
time_unit
::
invalid
;
}
/// Returns `count == 0`.
constexpr
bool
is_zero
()
const
{
return
count
==
0
;
}
time_unit
unit
;
uint64_t
count
;
};
/// @relates duration
template
<
class
Inspector
>
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
duration
&
x
)
{
return
f
(
x
.
unit
,
x
.
count
);
}
/// @relates duration
CAF_CORE_EXPORT
std
::
string
to_string
(
const
duration
&
x
);
/// @relates duration
CAF_CORE_EXPORT
bool
operator
==
(
const
duration
&
lhs
,
const
duration
&
rhs
);
/// @relates duration
inline
bool
operator
!=
(
const
duration
&
lhs
,
const
duration
&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
/// @relates duration
template
<
class
Clock
,
class
Duration
>
std
::
chrono
::
time_point
<
Clock
,
Duration
>&
operator
+=
(
std
::
chrono
::
time_point
<
Clock
,
Duration
>&
lhs
,
const
duration
&
rhs
)
{
switch
(
rhs
.
unit
)
{
case
time_unit
:
:
invalid
:
break
;
case
time_unit
:
:
minutes
:
lhs
+=
std
::
chrono
::
minutes
(
rhs
.
count
);
break
;
case
time_unit
:
:
seconds
:
lhs
+=
std
::
chrono
::
seconds
(
rhs
.
count
);
break
;
case
time_unit
:
:
milliseconds
:
lhs
+=
std
::
chrono
::
milliseconds
(
rhs
.
count
);
break
;
case
time_unit
:
:
microseconds
:
lhs
+=
std
::
chrono
::
microseconds
(
rhs
.
count
);
break
;
case
time_unit
:
:
nanoseconds
:
lhs
+=
std
::
chrono
::
nanoseconds
(
rhs
.
count
);
break
;
}
return
lhs
;
}
}
// namespace caf
libcaf_core/caf/function_view.hpp
View file @
3d5ddb6e
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "caf/expected.hpp"
#include "caf/expected.hpp"
#include "caf/response_type.hpp"
#include "caf/response_type.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/timespan.hpp"
#include "caf/typed_actor.hpp"
#include "caf/typed_actor.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -35,7 +36,7 @@ class function_view_storage {
...
@@ -35,7 +36,7 @@ class function_view_storage {
public:
public:
using
type
=
function_view_storage
;
using
type
=
function_view_storage
;
function_view_storage
(
T
&
storage
)
:
storage_
(
&
storage
)
{
explicit
function_view_storage
(
T
&
storage
)
:
storage_
(
&
storage
)
{
// nop
// nop
}
}
...
@@ -52,7 +53,8 @@ class function_view_storage<std::tuple<Ts...>> {
...
@@ -52,7 +53,8 @@ class function_view_storage<std::tuple<Ts...>> {
public:
public:
using
type
=
function_view_storage
;
using
type
=
function_view_storage
;
function_view_storage
(
std
::
tuple
<
Ts
...
>&
storage
)
:
storage_
(
&
storage
)
{
explicit
function_view_storage
(
std
::
tuple
<
Ts
...
>&
storage
)
:
storage_
(
&
storage
)
{
// nop
// nop
}
}
...
@@ -69,7 +71,7 @@ class function_view_storage<unit_t> {
...
@@ -69,7 +71,7 @@ class function_view_storage<unit_t> {
public:
public:
using
type
=
function_view_storage
;
using
type
=
function_view_storage
;
function_view_storage
(
unit_t
&
)
{
explicit
function_view_storage
(
unit_t
&
)
{
// nop
// nop
}
}
...
@@ -81,7 +83,7 @@ public:
...
@@ -81,7 +83,7 @@ public:
struct
CAF_CORE_EXPORT
function_view_storage_catch_all
{
struct
CAF_CORE_EXPORT
function_view_storage_catch_all
{
message
*
storage_
;
message
*
storage_
;
function_view_storage_catch_all
(
message
&
ptr
)
:
storage_
(
&
ptr
)
{
explicit
function_view_storage_catch_all
(
message
&
ptr
)
:
storage_
(
&
ptr
)
{
// nop
// nop
}
}
...
@@ -135,11 +137,20 @@ class function_view {
...
@@ -135,11 +137,20 @@ class function_view {
public:
public:
using
type
=
Actor
;
using
type
=
Actor
;
function_view
(
duration
rel_timeout
=
infinite
)
:
timeout
(
rel_timeout
)
{
function_view
(
)
:
timeout
(
infinite
)
{
// nop
// nop
}
}
function_view
(
type
impl
,
duration
rel_timeout
=
infinite
)
explicit
function_view
(
timespan
rel_timeout
)
:
timeout
(
rel_timeout
)
{
// nop
}
explicit
function_view
(
type
impl
)
:
timeout
(
infinite
),
impl_
(
std
::
move
(
impl
))
{
new_self
(
impl_
);
}
function_view
(
type
impl
,
timespan
rel_timeout
)
:
timeout
(
rel_timeout
),
impl_
(
std
::
move
(
impl
))
{
:
timeout
(
rel_timeout
),
impl_
(
std
::
move
(
impl
))
{
new_self
(
impl_
);
new_self
(
impl_
);
}
}
...
@@ -206,7 +217,7 @@ public:
...
@@ -206,7 +217,7 @@ public:
return
impl_
;
return
impl_
;
}
}
duratio
n
timeout
;
timespa
n
timeout
;
private:
private:
template
<
class
T
>
template
<
class
T
>
...
@@ -258,8 +269,8 @@ bool operator!=(std::nullptr_t x, const function_view<T>& y) {
...
@@ -258,8 +269,8 @@ bool operator!=(std::nullptr_t x, const function_view<T>& y) {
/// @relates function_view
/// @relates function_view
/// @experimental
/// @experimental
template
<
class
T
>
template
<
class
T
>
function_view
<
T
>
make_function_view
(
const
T
&
x
,
duratio
n
t
=
infinite
)
{
auto
make_function_view
(
const
T
&
x
,
timespa
n
t
=
infinite
)
{
return
{
x
,
t
};
return
function_view
<
T
>
{
x
,
t
};
}
}
}
// namespace caf
}
// namespace caf
libcaf_core/caf/fwd.hpp
View file @
3d5ddb6e
...
@@ -105,7 +105,6 @@ class config_value;
...
@@ -105,7 +105,6 @@ class config_value;
class
deserializer
;
class
deserializer
;
class
downstream_manager
;
class
downstream_manager
;
class
downstream_manager_base
;
class
downstream_manager_base
;
class
duration
;
class
error
;
class
error
;
class
event_based_actor
;
class
event_based_actor
;
class
execution_unit
;
class
execution_unit
;
...
...
libcaf_core/caf/local_actor.hpp
View file @
3d5ddb6e
...
@@ -38,7 +38,6 @@
...
@@ -38,7 +38,6 @@
#include "caf/detail/type_traits.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/unique_function.hpp"
#include "caf/detail/unique_function.hpp"
#include "caf/duration.hpp"
#include "caf/error.hpp"
#include "caf/error.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/message.hpp"
#include "caf/message.hpp"
...
@@ -50,6 +49,7 @@
...
@@ -50,6 +49,7 @@
#include "caf/response_type.hpp"
#include "caf/response_type.hpp"
#include "caf/resumable.hpp"
#include "caf/resumable.hpp"
#include "caf/spawn_options.hpp"
#include "caf/spawn_options.hpp"
#include "caf/timespan.hpp"
#include "caf/typed_actor.hpp"
#include "caf/typed_actor.hpp"
#include "caf/typed_response_promise.hpp"
#include "caf/typed_response_promise.hpp"
...
@@ -91,7 +91,7 @@ public:
...
@@ -91,7 +91,7 @@ public:
/// Requests a new timeout for `mid`.
/// Requests a new timeout for `mid`.
/// @pre `mid.is_request()`
/// @pre `mid.is_request()`
void
request_response_timeout
(
const
duration
&
d
,
message_id
mid
);
void
request_response_timeout
(
timespan
d
,
message_id
mid
);
// -- spawn functions --------------------------------------------------------
// -- spawn functions --------------------------------------------------------
...
...
libcaf_core/caf/message_handler.hpp
View file @
3d5ddb6e
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
#include "caf/behavior.hpp"
#include "caf/behavior.hpp"
#include "caf/detail/behavior_impl.hpp"
#include "caf/detail/behavior_impl.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/duration.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/match_case.hpp"
#include "caf/match_case.hpp"
...
...
libcaf_core/caf/mixin/requester.hpp
View file @
3d5ddb6e
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
#include "caf/actor.hpp"
#include "caf/actor.hpp"
#include "caf/check_typed_input.hpp"
#include "caf/check_typed_input.hpp"
#include "caf/detail/profiled_send.hpp"
#include "caf/detail/profiled_send.hpp"
#include "caf/duration.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/message.hpp"
#include "caf/message.hpp"
#include "caf/message_id.hpp"
#include "caf/message_id.hpp"
...
@@ -58,9 +57,10 @@ public:
...
@@ -58,9 +57,10 @@ public:
/// @returns A handle identifying a future-like handle to the response.
/// @returns A handle identifying a future-like handle to the response.
/// @warning The returned handle is actor specific and the response to the
/// @warning The returned handle is actor specific and the response to the
/// sent message cannot be received by another actor.
/// sent message cannot be received by another actor.
template
<
message_priority
P
=
message_priority
::
normal
,
class
Handle
=
actor
,
template
<
message_priority
P
=
message_priority
::
normal
,
class
Rep
=
int
,
class
...
Ts
>
class
Period
=
std
::
ratio
<
1
>,
class
Handle
=
actor
,
class
...
Ts
>
auto
request
(
const
Handle
&
dest
,
const
duration
&
timeout
,
Ts
&&
...
xs
)
{
auto
request
(
const
Handle
&
dest
,
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
,
Ts
&&
...
xs
)
{
using
namespace
detail
;
using
namespace
detail
;
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
using
token
=
type_list
<
implicit_conversions_t
<
decay_t
<
Ts
>>
...
>
;
using
token
=
type_list
<
implicit_conversions_t
<
decay_t
<
Ts
>>
...
>
;
...
@@ -84,14 +84,6 @@ public:
...
@@ -84,14 +84,6 @@ public:
return
handle_type
{
self
,
req_id
.
response_id
()};
return
handle_type
{
self
,
req_id
.
response_id
()};
}
}
/// @copydoc request
template
<
message_priority
P
=
message_priority
::
normal
,
class
Rep
=
int
,
class
Period
=
std
::
ratio
<
1
>,
class
Handle
=
actor
,
class
...
Ts
>
auto
request
(
const
Handle
&
dest
,
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
,
Ts
&&
...
xs
)
{
return
request
(
dest
,
duration
{
timeout
},
std
::
forward
<
Ts
>
(
xs
)...);
}
/// Sends `{xs...}` to each actor in the range `destinations` as a synchronous
/// Sends `{xs...}` to each actor in the range `destinations` as a synchronous
/// message. Response messages get combined into a single result according to
/// message. Response messages get combined into a single result according to
/// the `MergePolicy`.
/// the `MergePolicy`.
...
@@ -113,10 +105,10 @@ public:
...
@@ -113,10 +105,10 @@ public:
/// @note The returned handle is actor-specific. Only the actor that called
/// @note The returned handle is actor-specific. Only the actor that called
/// `request` can use it for setting response handlers.
/// `request` can use it for setting response handlers.
template
<
template
<
class
>
class
MergePolicy
,
template
<
template
<
class
>
class
MergePolicy
,
message_priority
Prio
=
message_priority
::
normal
,
class
Container
,
message_priority
Prio
=
message_priority
::
normal
,
class
Rep
=
int
,
class
...
Ts
>
class
Period
=
std
::
ratio
<
1
>,
class
Container
,
class
...
Ts
>
auto
fan_out_request
(
const
Container
&
destinations
,
const
duration
&
timeout
,
auto
fan_out_request
(
const
Container
&
destinations
,
Ts
&&
...
xs
)
{
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
,
Ts
&&
...
xs
)
{
using
handle_type
=
typename
Container
::
value_type
;
using
handle_type
=
typename
Container
::
value_type
;
using
namespace
detail
;
using
namespace
detail
;
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
...
@@ -148,16 +140,6 @@ public:
...
@@ -148,16 +140,6 @@ public:
using
result_type
=
response_handle
<
Subtype
,
MergePolicy
<
response_type
>>
;
using
result_type
=
response_handle
<
Subtype
,
MergePolicy
<
response_type
>>
;
return
result_type
{
dptr
,
std
::
move
(
ids
)};
return
result_type
{
dptr
,
std
::
move
(
ids
)};
}
}
/// @copydoc fan_out_request
template
<
template
<
class
>
class
MergePolicy
,
message_priority
Prio
=
message_priority
::
normal
,
class
Rep
,
class
Period
,
class
Container
,
class
...
Ts
>
auto
fan_out_request
(
const
Container
&
destinations
,
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
,
Ts
&&
...
xs
)
{
return
request
<
MergePolicy
,
Prio
>
(
destinations
,
duration
{
timeout
},
std
::
forward
<
Ts
>
(
xs
)...);
}
};
};
}
// namespace caf::mixin
}
// namespace caf::mixin
libcaf_core/caf/mixin/sender.hpp
View file @
3d5ddb6e
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include "caf/check_typed_input.hpp"
#include "caf/check_typed_input.hpp"
#include "caf/detail/profiled_send.hpp"
#include "caf/detail/profiled_send.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/duration.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/message.hpp"
#include "caf/message.hpp"
#include "caf/message_priority.hpp"
#include "caf/message_priority.hpp"
...
...
libcaf_core/caf/scheduler/abstract_coordinator.hpp
View file @
3d5ddb6e
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
#include "caf/actor_system.hpp"
#include "caf/actor_system.hpp"
#include "caf/atom.hpp"
#include "caf/atom.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/duration.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/message.hpp"
#include "caf/message.hpp"
...
...
libcaf_core/caf/timeout_definition.hpp
View file @
3d5ddb6e
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#include <type_traits>
#include <type_traits>
#include "caf/detail/core_export.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/
duratio
n.hpp"
#include "caf/
timespa
n.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -31,7 +31,7 @@ namespace detail {
...
@@ -31,7 +31,7 @@ namespace detail {
class
behavior_impl
;
class
behavior_impl
;
CAF_CORE_EXPORT
behavior_impl
*
CAF_CORE_EXPORT
behavior_impl
*
new_default_behavior
(
duratio
n
d
,
std
::
function
<
void
()
>
fun
);
new_default_behavior
(
timespa
n
d
,
std
::
function
<
void
()
>
fun
);
}
// namespace detail
}
// namespace detail
...
@@ -39,7 +39,7 @@ template <class F>
...
@@ -39,7 +39,7 @@ template <class F>
struct
timeout_definition
{
struct
timeout_definition
{
static
constexpr
bool
may_have_timeout
=
true
;
static
constexpr
bool
may_have_timeout
=
true
;
duratio
n
timeout
;
timespa
n
timeout
;
F
handler
;
F
handler
;
...
@@ -51,7 +51,8 @@ struct timeout_definition {
...
@@ -51,7 +51,8 @@ struct timeout_definition {
timeout_definition
(
timeout_definition
&&
)
=
default
;
timeout_definition
(
timeout_definition
&&
)
=
default
;
timeout_definition
(
const
timeout_definition
&
)
=
default
;
timeout_definition
(
const
timeout_definition
&
)
=
default
;
timeout_definition
(
duration
d
,
F
&&
f
)
:
timeout
(
d
),
handler
(
std
::
move
(
f
))
{
timeout_definition
(
timespan
timeout
,
F
&&
f
)
:
timeout
(
timeout
),
handler
(
std
::
move
(
f
))
{
// nop
// nop
}
}
...
...
libcaf_core/caf/timespan.hpp
View file @
3d5ddb6e
...
@@ -20,10 +20,15 @@
...
@@ -20,10 +20,15 @@
#include <chrono>
#include <chrono>
#include <cstdint>
#include <cstdint>
#include <limits>
namespace
caf
{
namespace
caf
{
/// A portable timespan type with nanosecond resolution.
/// A portable timespan type with nanosecond resolution.
using
timespan
=
std
::
chrono
::
duration
<
int64_t
,
std
::
nano
>
;
using
timespan
=
std
::
chrono
::
duration
<
int64_t
,
std
::
nano
>
;
/// Constant representing an infinite amount of time.
static
constexpr
timespan
infinite
=
timespan
{
std
::
numeric_limits
<
int64_t
>::
max
()};
}
// namespace caf
}
// namespace caf
libcaf_core/caf/type_nr.hpp
View file @
3d5ddb6e
...
@@ -49,7 +49,6 @@ using sorted_builtin_types
...
@@ -49,7 +49,6 @@ using sorted_builtin_types
config_value
,
// @config_value
config_value
,
// @config_value
down_msg
,
// @down
down_msg
,
// @down
downstream_msg
,
// @downstream_msg
downstream_msg
,
// @downstream_msg
duration
,
// @duration
error
,
// @error
error
,
// @error
exit_msg
,
// @exit
exit_msg
,
// @exit
group
,
// @group
group
,
// @group
...
...
libcaf_core/caf/typed_behavior.hpp
View file @
3d5ddb6e
...
@@ -210,7 +210,7 @@ public:
...
@@ -210,7 +210,7 @@ public:
/// Returns the duration after which receives using
/// Returns the duration after which receives using
/// this behavior should time out.
/// this behavior should time out.
const
duration
&
timeout
()
cons
t
{
timespan
timeout
()
const
noexcep
t
{
return
bhvr_
.
timeout
();
return
bhvr_
.
timeout
();
}
}
...
...
libcaf_core/caf/uniform_type_info_map.hpp
View file @
3d5ddb6e
...
@@ -32,7 +32,6 @@
...
@@ -32,7 +32,6 @@
#include "caf/detail/core_export.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/detail/shared_spinlock.hpp"
#include "caf/detail/shared_spinlock.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/duration.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/node_id.hpp"
#include "caf/node_id.hpp"
#include "caf/system_messages.hpp"
#include "caf/system_messages.hpp"
...
...
libcaf_core/src/blocking_actor.cpp
View file @
3d5ddb6e
...
@@ -247,7 +247,7 @@ void blocking_actor::receive_impl(receive_cond& rcc,
...
@@ -247,7 +247,7 @@ void blocking_actor::receive_impl(receive_cond& rcc,
do
{
do
{
// Reset the timeout each iteration.
// Reset the timeout each iteration.
auto
rel_tout
=
bhvr
.
timeout
();
auto
rel_tout
=
bhvr
.
timeout
();
if
(
!
rel_tout
.
valid
()
)
{
if
(
rel_tout
==
infinite
)
{
await_data
();
await_data
();
}
else
{
}
else
{
auto
abs_tout
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
abs_tout
=
std
::
chrono
::
high_resolution_clock
::
now
();
...
@@ -289,14 +289,12 @@ void blocking_actor::varargs_tup_receive(receive_cond& rcc, message_id mid,
...
@@ -289,14 +289,12 @@ void blocking_actor::varargs_tup_receive(receive_cond& rcc, message_id mid,
std
::
tuple
<
behavior
&>&
tup
)
{
std
::
tuple
<
behavior
&>&
tup
)
{
using
namespace
detail
;
using
namespace
detail
;
auto
&
bhvr
=
std
::
get
<
0
>
(
tup
);
auto
&
bhvr
=
std
::
get
<
0
>
(
tup
);
if
(
bhvr
.
timeout
().
valid
())
{
if
(
bhvr
.
timeout
()
==
infinite
)
{
auto
tmp
=
after
(
bhvr
.
timeout
())
>>
[
&
]
{
auto
fun
=
make_blocking_behavior
(
&
bhvr
);
bhvr
.
handle_timeout
();
};
auto
fun
=
make_blocking_behavior
(
&
bhvr
,
std
::
move
(
tmp
));
receive_impl
(
rcc
,
mid
,
fun
);
receive_impl
(
rcc
,
mid
,
fun
);
}
else
{
}
else
{
auto
fun
=
make_blocking_behavior
(
&
bhvr
);
auto
tmp
=
after
(
bhvr
.
timeout
())
>>
[
&
]
{
bhvr
.
handle_timeout
();
};
auto
fun
=
make_blocking_behavior
(
&
bhvr
,
std
::
move
(
tmp
));
receive_impl
(
rcc
,
mid
,
fun
);
receive_impl
(
rcc
,
mid
,
fun
);
}
}
}
}
...
...
libcaf_core/src/detail/behavior_impl.cpp
View file @
3d5ddb6e
...
@@ -78,7 +78,12 @@ behavior_impl::~behavior_impl() {
...
@@ -78,7 +78,12 @@ behavior_impl::~behavior_impl() {
// nop
// nop
}
}
behavior_impl
::
behavior_impl
(
duration
tout
)
behavior_impl
::
behavior_impl
()
:
timeout_
(
infinite
),
begin_
(
nullptr
),
end_
(
nullptr
)
{
// nop
}
behavior_impl
::
behavior_impl
(
timespan
tout
)
:
timeout_
(
tout
),
begin_
(
nullptr
),
end_
(
nullptr
)
{
:
timeout_
(
tout
),
begin_
(
nullptr
),
end_
(
nullptr
)
{
// nop
// nop
}
}
...
...
libcaf_core/src/detail/blocking_behavior.cpp
View file @
3d5ddb6e
...
@@ -32,8 +32,8 @@ result<message> blocking_behavior::fallback(message_view&) {
...
@@ -32,8 +32,8 @@ result<message> blocking_behavior::fallback(message_view&) {
return
skip
;
return
skip
;
}
}
duratio
n
blocking_behavior
::
timeout
()
{
timespa
n
blocking_behavior
::
timeout
()
{
return
{}
;
return
infinite
;
}
}
void
blocking_behavior
::
handle_timeout
()
{
void
blocking_behavior
::
handle_timeout
()
{
...
...
libcaf_core/src/duration.cpp
deleted
100644 → 0
View file @
ea5b4f17
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include <sstream>
#include "caf/duration.hpp"
namespace
caf
{
namespace
{
const
char
*
time_unit_strings
[]
=
{
"invalid"
,
"minutes"
,
"seconds"
,
"milliseconds"
,
"microseconds"
,
"nanoseconds"
};
const
char
*
time_unit_short_strings
[]
=
{
"?"
,
"min"
,
"s"
,
"ms"
,
"us"
,
"ns"
};
}
// namespace
std
::
string
to_string
(
time_unit
x
)
{
return
time_unit_strings
[
static_cast
<
uint32_t
>
(
x
)];
}
std
::
string
to_string
(
const
duration
&
x
)
{
if
(
x
.
unit
==
time_unit
::
invalid
)
return
"infinite"
;
auto
result
=
std
::
to_string
(
x
.
count
);
result
+=
time_unit_short_strings
[
static_cast
<
uint32_t
>
(
x
.
unit
)];
return
result
;
}
bool
operator
==
(
const
duration
&
lhs
,
const
duration
&
rhs
)
{
return
lhs
.
unit
==
rhs
.
unit
&&
lhs
.
count
==
rhs
.
count
;
}
}
// namespace caf
libcaf_core/src/local_actor.cpp
View file @
3d5ddb6e
...
@@ -60,12 +60,12 @@ void local_actor::on_destroy() {
...
@@ -60,12 +60,12 @@ void local_actor::on_destroy() {
}
}
}
}
void
local_actor
::
request_response_timeout
(
const
duration
&
d
,
message_id
mid
)
{
void
local_actor
::
request_response_timeout
(
timespan
timeout
,
message_id
mid
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
d
)
<<
CAF_ARG
(
mid
));
CAF_LOG_TRACE
(
CAF_ARG
(
timeout
)
<<
CAF_ARG
(
mid
));
if
(
!
d
.
valid
()
)
if
(
timeout
==
infinite
)
return
;
return
;
auto
t
=
clock
().
now
();
auto
t
=
clock
().
now
();
t
+=
d
;
t
+=
timeout
;
clock
().
set_request_timeout
(
t
,
this
,
mid
.
response_id
());
clock
().
set_request_timeout
(
t
,
this
,
mid
.
response_id
());
}
}
...
...
libcaf_core/src/scheduled_actor.cpp
View file @
3d5ddb6e
...
@@ -480,12 +480,12 @@ uint64_t scheduled_actor::set_receive_timeout() {
...
@@ -480,12 +480,12 @@ uint64_t scheduled_actor::set_receive_timeout() {
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
if
(
bhvr_stack_
.
empty
())
if
(
bhvr_stack_
.
empty
())
return
0
;
return
0
;
auto
d
=
bhvr_stack_
.
back
().
timeout
();
auto
timeout
=
bhvr_stack_
.
back
().
timeout
();
if
(
!
d
.
valid
()
)
{
if
(
timeout
==
infinite
)
{
unsetf
(
has_timeout_flag
);
unsetf
(
has_timeout_flag
);
return
0
;
return
0
;
}
}
if
(
d
.
is_zero
()
)
{
if
(
timeout
==
timespan
{
0
}
)
{
// immediately enqueue timeout message if duration == 0s
// immediately enqueue timeout message if duration == 0s
auto
id
=
++
timeout_id_
;
auto
id
=
++
timeout_id_
;
auto
type
=
receive_atom
::
value
;
auto
type
=
receive_atom
::
value
;
...
@@ -493,7 +493,7 @@ uint64_t scheduled_actor::set_receive_timeout() {
...
@@ -493,7 +493,7 @@ uint64_t scheduled_actor::set_receive_timeout() {
return
id
;
return
id
;
}
}
auto
t
=
clock
().
now
();
auto
t
=
clock
().
now
();
t
+=
d
;
t
+=
timeout
;
return
set_receive_timeout
(
t
);
return
set_receive_timeout
(
t
);
}
}
...
@@ -532,14 +532,14 @@ uint64_t scheduled_actor::set_stream_timeout(actor_clock::time_point x) {
...
@@ -532,14 +532,14 @@ uint64_t scheduled_actor::set_stream_timeout(actor_clock::time_point x) {
void
scheduled_actor
::
add_awaited_response_handler
(
message_id
response_id
,
void
scheduled_actor
::
add_awaited_response_handler
(
message_id
response_id
,
behavior
bhvr
)
{
behavior
bhvr
)
{
if
(
bhvr
.
timeout
()
.
valid
()
)
if
(
bhvr
.
timeout
()
!=
infinite
)
request_response_timeout
(
bhvr
.
timeout
(),
response_id
);
request_response_timeout
(
bhvr
.
timeout
(),
response_id
);
awaited_responses_
.
emplace_front
(
response_id
,
std
::
move
(
bhvr
));
awaited_responses_
.
emplace_front
(
response_id
,
std
::
move
(
bhvr
));
}
}
void
scheduled_actor
::
add_multiplexed_response_handler
(
message_id
response_id
,
void
scheduled_actor
::
add_multiplexed_response_handler
(
message_id
response_id
,
behavior
bhvr
)
{
behavior
bhvr
)
{
if
(
bhvr
.
timeout
()
.
valid
()
)
if
(
bhvr
.
timeout
()
!=
infinite
)
request_response_timeout
(
bhvr
.
timeout
(),
response_id
);
request_response_timeout
(
bhvr
.
timeout
(),
response_id
);
multiplexed_responses_
.
emplace
(
response_id
,
std
::
move
(
bhvr
));
multiplexed_responses_
.
emplace
(
response_id
,
std
::
move
(
bhvr
));
}
}
...
...
libcaf_core/src/scheduler/abstract_coordinator.cpp
View file @
3d5ddb6e
...
@@ -32,7 +32,6 @@
...
@@ -32,7 +32,6 @@
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/after.hpp"
#include "caf/after.hpp"
#include "caf/defaults.hpp"
#include "caf/defaults.hpp"
#include "caf/duration.hpp"
#include "caf/logger.hpp"
#include "caf/logger.hpp"
#include "caf/others.hpp"
#include "caf/others.hpp"
#include "caf/policy/work_stealing.hpp"
#include "caf/policy/work_stealing.hpp"
...
...
libcaf_core/src/uniform_type_info_map.cpp
View file @
3d5ddb6e
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
#include "caf/actor_system.hpp"
#include "caf/actor_system.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/downstream_msg.hpp"
#include "caf/downstream_msg.hpp"
#include "caf/duration.hpp"
#include "caf/group.hpp"
#include "caf/group.hpp"
#include "caf/locks.hpp"
#include "caf/locks.hpp"
#include "caf/logger.hpp"
#include "caf/logger.hpp"
...
@@ -64,7 +63,6 @@ const char* numbered_type_names[] = {
...
@@ -64,7 +63,6 @@ const char* numbered_type_names[] = {
"@config_value"
,
"@config_value"
,
"@down"
,
"@down"
,
"@downstream_msg"
,
"@downstream_msg"
,
"@duration"
,
"@error"
,
"@error"
,
"@exit"
,
"@exit"
,
"@group"
,
"@group"
,
...
...
libcaf_core/test/actor_clock.cpp
View file @
3d5ddb6e
...
@@ -30,9 +30,9 @@
...
@@ -30,9 +30,9 @@
using
namespace
caf
;
using
namespace
caf
;
namespace
{
using
namespace
std
::
chrono_literals
;
using
std
::
chrono
::
seconds
;
namespace
{
struct
testee_state
{
struct
testee_state
{
uint64_t
timeout_id
=
41
;
uint64_t
timeout_id
=
41
;
...
@@ -42,17 +42,17 @@ behavior testee(stateful_actor<testee_state, raw_event_based_actor>* self,
...
@@ -42,17 +42,17 @@ behavior testee(stateful_actor<testee_state, raw_event_based_actor>* self,
detail
::
test_actor_clock
*
t
)
{
detail
::
test_actor_clock
*
t
)
{
return
{
return
{
[
=
](
ok_atom
)
{
[
=
](
ok_atom
)
{
auto
n
=
t
->
now
()
+
seconds
(
10
)
;
auto
n
=
t
->
now
()
+
10s
;
self
->
state
.
timeout_id
+=
1
;
self
->
state
.
timeout_id
+=
1
;
t
->
set_ordinary_timeout
(
n
,
self
,
atom
(
""
),
self
->
state
.
timeout_id
);
t
->
set_ordinary_timeout
(
n
,
self
,
atom
(
""
),
self
->
state
.
timeout_id
);
},
},
[
=
](
add_atom
)
{
[
=
](
add_atom
)
{
auto
n
=
t
->
now
()
+
seconds
(
10
)
;
auto
n
=
t
->
now
()
+
10s
;
self
->
state
.
timeout_id
+=
1
;
self
->
state
.
timeout_id
+=
1
;
t
->
set_multi_timeout
(
n
,
self
,
atom
(
""
),
self
->
state
.
timeout_id
);
t
->
set_multi_timeout
(
n
,
self
,
atom
(
""
),
self
->
state
.
timeout_id
);
},
},
[
=
](
put_atom
)
{
[
=
](
put_atom
)
{
auto
n
=
t
->
now
()
+
seconds
(
10
)
;
auto
n
=
t
->
now
()
+
10s
;
self
->
state
.
timeout_id
+=
1
;
self
->
state
.
timeout_id
+=
1
;
auto
mid
=
make_message_id
(
self
->
state
.
timeout_id
).
response_id
();
auto
mid
=
make_message_id
(
self
->
state
.
timeout_id
).
response_id
();
t
->
set_request_timeout
(
n
,
self
,
mid
);
t
->
set_request_timeout
(
n
,
self
,
mid
);
...
@@ -66,12 +66,8 @@ behavior testee(stateful_actor<testee_state, raw_event_based_actor>* self,
...
@@ -66,12 +66,8 @@ behavior testee(stateful_actor<testee_state, raw_event_based_actor>* self,
[](
const
std
::
string
&
)
{
[](
const
std
::
string
&
)
{
// nop
// nop
},
},
[
=
](
group
&
grp
)
{
[
=
](
group
&
grp
)
{
self
->
join
(
grp
);
},
self
->
join
(
grp
);
[
=
](
exit_msg
&
x
)
{
self
->
quit
(
x
.
reason
);
},
},
[
=
](
exit_msg
&
x
)
{
self
->
quit
(
x
.
reason
);
}
};
};
}
}
...
@@ -103,7 +99,7 @@ CAF_TEST(single_receive_timeout) {
...
@@ -103,7 +99,7 @@ CAF_TEST(single_receive_timeout) {
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Advance time to send timeout message.
// Advance time to send timeout message.
t
.
advance_time
(
seconds
(
10
)
);
t
.
advance_time
(
10s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
...
@@ -122,7 +118,7 @@ CAF_TEST(override_receive_timeout) {
...
@@ -122,7 +118,7 @@ CAF_TEST(override_receive_timeout) {
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Advance time to send timeout message.
// Advance time to send timeout message.
t
.
advance_time
(
seconds
(
10
)
);
t
.
advance_time
(
10s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
...
@@ -136,20 +132,20 @@ CAF_TEST(multi_timeout) {
...
@@ -136,20 +132,20 @@ CAF_TEST(multi_timeout) {
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Advance time just a little bit.
// Advance time just a little bit.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
// Have AUT call t.set_multi_timeout() again.
// Have AUT call t.set_multi_timeout() again.
self
->
send
(
aut
,
add_atom
::
value
);
self
->
send
(
aut
,
add_atom
::
value
);
expect
((
add_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
expect
((
add_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
// Advance time to send timeout message.
// Advance time to send timeout message.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
42
}));
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
42
}));
// Advance time to send second timeout message.
// Advance time to send second timeout message.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
...
@@ -163,25 +159,24 @@ CAF_TEST(mixed_receive_and_multi_timeouts) {
...
@@ -163,25 +159,24 @@ CAF_TEST(mixed_receive_and_multi_timeouts) {
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Advance time just a little bit.
// Advance time just a little bit.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
// Have AUT call t.set_multi_timeout() again.
// Have AUT call t.set_multi_timeout() again.
self
->
send
(
aut
,
ok_atom
::
value
);
self
->
send
(
aut
,
ok_atom
::
value
);
expect
((
ok_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
expect
((
ok_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
// Advance time to send timeout message.
// Advance time to send timeout message.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
42
}));
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
42
}));
// Advance time to send second timeout message.
// Advance time to send second timeout message.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
43
}));
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
43
}));
}
}
CAF_TEST
(
single_request_timeout
)
{
CAF_TEST
(
single_request_timeout
)
{
...
@@ -191,7 +186,7 @@ CAF_TEST(single_request_timeout) {
...
@@ -191,7 +186,7 @@ CAF_TEST(single_request_timeout) {
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Advance time to send timeout message.
// Advance time to send timeout message.
t
.
advance_time
(
seconds
(
10
)
);
t
.
advance_time
(
10s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
...
@@ -205,20 +200,20 @@ CAF_TEST(mixed_receive_and_request_timeouts) {
...
@@ -205,20 +200,20 @@ CAF_TEST(mixed_receive_and_request_timeouts) {
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Cause the request timeout to arrive later.
// Cause the request timeout to arrive later.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
// Have AUT call t.set_request_timeout().
// Have AUT call t.set_request_timeout().
self
->
send
(
aut
,
put_atom
::
value
);
self
->
send
(
aut
,
put_atom
::
value
);
expect
((
put_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
expect
((
put_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
// Advance time to send receive timeout message.
// Advance time to send receive timeout message.
t
.
advance_time
(
seconds
(
5
)
);
t
.
advance_time
(
5s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
42
}));
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
42
}));
// Advance time to send request timeout message.
// Advance time to send request timeout message.
t
.
advance_time
(
seconds
(
10
)
);
t
.
advance_time
(
10s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the timeout.
// Have AUT receive the timeout.
...
@@ -227,15 +222,15 @@ CAF_TEST(mixed_receive_and_request_timeouts) {
...
@@ -227,15 +222,15 @@ CAF_TEST(mixed_receive_and_request_timeouts) {
CAF_TEST
(
delay_actor_message
)
{
CAF_TEST
(
delay_actor_message
)
{
// Schedule a message for now + 10s.
// Schedule a message for now + 10s.
auto
n
=
t
.
now
()
+
seconds
(
10
)
;
auto
n
=
t
.
now
()
+
10s
;
auto
autptr
=
actor_cast
<
strong_actor_ptr
>
(
aut
);
auto
autptr
=
actor_cast
<
strong_actor_ptr
>
(
aut
);
t
.
schedule_message
(
n
,
autptr
,
t
.
schedule_message
(
n
,
autptr
,
make_mailbox_element
(
autptr
,
make_message_id
(),
make_mailbox_element
(
autptr
,
make_message_id
(),
no_stages
,
no_stages
,
"foo"
));
"foo"
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Advance time to send the message.
// Advance time to send the message.
t
.
advance_time
(
seconds
(
10
)
);
t
.
advance_time
(
10s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the message.
// Have AUT receive the message.
...
@@ -248,13 +243,13 @@ CAF_TEST(delay_group_message) {
...
@@ -248,13 +243,13 @@ CAF_TEST(delay_group_message) {
self
->
send
(
aut
,
grp
);
self
->
send
(
aut
,
grp
);
expect
((
group
),
from
(
self
).
to
(
aut
).
with
(
_
));
expect
((
group
),
from
(
self
).
to
(
aut
).
with
(
_
));
// Schedule a message for now + 10s.
// Schedule a message for now + 10s.
auto
n
=
t
.
now
()
+
seconds
(
10
)
;
auto
n
=
t
.
now
()
+
10s
;
auto
autptr
=
actor_cast
<
strong_actor_ptr
>
(
aut
);
auto
autptr
=
actor_cast
<
strong_actor_ptr
>
(
aut
);
t
.
schedule_message
(
n
,
std
::
move
(
grp
),
autptr
,
make_message
(
"foo"
));
t
.
schedule_message
(
n
,
std
::
move
(
grp
),
autptr
,
make_message
(
"foo"
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Advance time to send the message.
// Advance time to send the message.
t
.
advance_time
(
seconds
(
10
)
);
t
.
advance_time
(
10s
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the message.
// Have AUT receive the message.
...
...
libcaf_core/test/binary_deserializer.cpp
View file @
3d5ddb6e
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/byte.hpp"
#include "caf/byte.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/duration.hpp"
#include "caf/timestamp.hpp"
#include "caf/timestamp.hpp"
using
namespace
caf
;
using
namespace
caf
;
...
@@ -55,7 +54,6 @@ struct test_data {
...
@@ -55,7 +54,6 @@ struct test_data {
int64_t
i64_
;
int64_t
i64_
;
float
f32_
;
float
f32_
;
double
f64_
;
double
f64_
;
caf
::
duration
dur_
;
caf
::
timestamp
ts_
;
caf
::
timestamp
ts_
;
test_enum
te_
;
test_enum
te_
;
std
::
string
str_
;
std
::
string
str_
;
...
@@ -70,7 +68,7 @@ bool operator==(const test_data& data, const test_data& other) {
...
@@ -70,7 +68,7 @@ bool operator==(const test_data& data, const test_data& other) {
template
<
class
Inspector
>
template
<
class
Inspector
>
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
test_data
&
x
)
{
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
test_data
&
x
)
{
return
f
(
caf
::
meta
::
type_name
(
"test_data"
),
x
.
i32_
,
x
.
i64_
,
x
.
f32_
,
x
.
f64_
,
return
f
(
caf
::
meta
::
type_name
(
"test_data"
),
x
.
i32_
,
x
.
i64_
,
x
.
f32_
,
x
.
f64_
,
x
.
dur_
,
x
.
ts_
,
x
.
te_
,
x
.
str_
);
x
.
ts_
,
x
.
te_
,
x
.
str_
);
}
}
struct
fixture
{
struct
fixture
{
...
@@ -189,13 +187,6 @@ CAF_TEST(container types) {
...
@@ -189,13 +187,6 @@ CAF_TEST(container types) {
}
}
CAF_TEST
(
binary
serializer
picks
up
inspect
functions
)
{
CAF_TEST
(
binary
serializer
picks
up
inspect
functions
)
{
SUBTEST
(
"duration"
)
{
CHECK_LOAD
(
duration
,
duration
(
time_unit
::
minutes
,
3
),
// Bytes 1-4 contain the time_unit.
0
_b
,
0
_b
,
0
_b
,
1
_b
,
// Bytes 5-12 contain the count.
0
_b
,
0
_b
,
0
_b
,
0
_b
,
0
_b
,
0
_b
,
0
_b
,
3
_b
);
}
SUBTEST
(
"node ID"
)
{
SUBTEST
(
"node ID"
)
{
auto
nid
=
make_node_id
(
123
,
"000102030405060708090A0B0C0D0E0F10111213"
);
auto
nid
=
make_node_id
(
123
,
"000102030405060708090A0B0C0D0E0F10111213"
);
CHECK_LOAD
(
node_id
,
unbox
(
nid
),
CHECK_LOAD
(
node_id
,
unbox
(
nid
),
...
@@ -213,7 +204,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
...
@@ -213,7 +204,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
-
1234567890123456789ll
,
-
1234567890123456789ll
,
3.45
,
3.45
,
54.3
,
54.3
,
caf
::
duration
(
caf
::
time_unit
::
seconds
,
123
),
caf
::
timestamp
{
caf
::
timestamp
::
duration
{
1478715821
*
1000000000ll
}},
caf
::
timestamp
{
caf
::
timestamp
::
duration
{
1478715821
*
1000000000ll
}},
test_enum
::
b
,
test_enum
::
b
,
"Lorem ipsum dolor sit amet."
};
"Lorem ipsum dolor sit amet."
};
...
@@ -226,10 +216,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
...
@@ -226,10 +216,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
0x40
_b
,
0x5C
_b
,
0xCC
_b
,
0xCD
_b
,
0x40
_b
,
0x5C
_b
,
0xCC
_b
,
0xCD
_b
,
// 64-bit f64_ member: 54.3
// 64-bit f64_ member: 54.3
0x40
_b
,
0x4B
_b
,
0x26
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x40
_b
,
0x4B
_b
,
0x26
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
// 32-bit dur_.unit member: time_unit::seconds
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x02
_b
,
// 64-bit dur_.count member: 123
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x7B
_b
,
// 64-bit ts_ member.
// 64-bit ts_ member.
0x14
_b
,
0x85
_b
,
0x74
_b
,
0x34
_b
,
0x62
_b
,
0x74
_b
,
0x82
_b
,
0x00
_b
,
0x14
_b
,
0x85
_b
,
0x74
_b
,
0x34
_b
,
0x62
_b
,
0x74
_b
,
0x82
_b
,
0x00
_b
,
// 32-bit te_ member: test_enum::b
// 32-bit te_ member: test_enum::b
...
...
libcaf_core/test/binary_serializer.cpp
View file @
3d5ddb6e
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/byte.hpp"
#include "caf/byte.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/duration.hpp"
#include "caf/timestamp.hpp"
#include "caf/timestamp.hpp"
using
namespace
caf
;
using
namespace
caf
;
...
@@ -55,7 +54,6 @@ struct test_data {
...
@@ -55,7 +54,6 @@ struct test_data {
int64_t
i64_
;
int64_t
i64_
;
float
f32_
;
float
f32_
;
double
f64_
;
double
f64_
;
caf
::
duration
dur_
;
caf
::
timestamp
ts_
;
caf
::
timestamp
ts_
;
test_enum
te_
;
test_enum
te_
;
std
::
string
str_
;
std
::
string
str_
;
...
@@ -64,7 +62,7 @@ struct test_data {
...
@@ -64,7 +62,7 @@ struct test_data {
template
<
class
Inspector
>
template
<
class
Inspector
>
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
test_data
&
x
)
{
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
test_data
&
x
)
{
return
f
(
caf
::
meta
::
type_name
(
"test_data"
),
x
.
i32_
,
x
.
i64_
,
x
.
f32_
,
x
.
f64_
,
return
f
(
caf
::
meta
::
type_name
(
"test_data"
),
x
.
i32_
,
x
.
i64_
,
x
.
f32_
,
x
.
f64_
,
x
.
dur_
,
x
.
ts_
,
x
.
te_
,
x
.
str_
);
x
.
ts_
,
x
.
te_
,
x
.
str_
);
}
}
struct
fixture
{
struct
fixture
{
...
@@ -182,13 +180,6 @@ CAF_TEST(container types) {
...
@@ -182,13 +180,6 @@ CAF_TEST(container types) {
}
}
CAF_TEST
(
binary
serializer
picks
up
inspect
functions
)
{
CAF_TEST
(
binary
serializer
picks
up
inspect
functions
)
{
SUBTEST
(
"duration"
)
{
CHECK_SAVE
(
duration
,
duration
(
time_unit
::
minutes
,
3
),
// Bytes 1-4 contain the time_unit.
0
_b
,
0
_b
,
0
_b
,
1
_b
,
// Bytes 5-12 contain the count.
0
_b
,
0
_b
,
0
_b
,
0
_b
,
0
_b
,
0
_b
,
0
_b
,
3
_b
);
}
SUBTEST
(
"node ID"
)
{
SUBTEST
(
"node ID"
)
{
auto
nid
=
make_node_id
(
123
,
"000102030405060708090A0B0C0D0E0F10111213"
);
auto
nid
=
make_node_id
(
123
,
"000102030405060708090A0B0C0D0E0F10111213"
);
CHECK_SAVE
(
node_id
,
unbox
(
nid
),
CHECK_SAVE
(
node_id
,
unbox
(
nid
),
...
@@ -206,7 +197,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
...
@@ -206,7 +197,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
-
1234567890123456789ll
,
-
1234567890123456789ll
,
3.45
,
3.45
,
54.3
,
54.3
,
caf
::
duration
(
caf
::
time_unit
::
seconds
,
123
),
ts
,
ts
,
test_enum
::
b
,
test_enum
::
b
,
"Lorem ipsum dolor sit amet."
};
"Lorem ipsum dolor sit amet."
};
...
@@ -219,10 +209,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
...
@@ -219,10 +209,6 @@ CAF_TEST(binary serializer picks up inspect functions) {
0x40
_b
,
0x5C
_b
,
0xCC
_b
,
0xCD
_b
,
0x40
_b
,
0x5C
_b
,
0xCC
_b
,
0xCD
_b
,
// 64-bit f64_ member: 54.3
// 64-bit f64_ member: 54.3
0x40
_b
,
0x4B
_b
,
0x26
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x40
_b
,
0x4B
_b
,
0x26
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
0x66
_b
,
// 32-bit dur_.unit member: time_unit::seconds
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x02
_b
,
// 64-bit dur_.count member: 123
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x00
_b
,
0x7B
_b
,
// 64-bit ts_ member.
// 64-bit ts_ member.
0x14
_b
,
0x85
_b
,
0x74
_b
,
0x34
_b
,
0x62
_b
,
0x74
_b
,
0x82
_b
,
0x00
_b
,
0x14
_b
,
0x85
_b
,
0x74
_b
,
0x34
_b
,
0x62
_b
,
0x74
_b
,
0x82
_b
,
0x00
_b
,
// 32-bit te_ member: test_enum::b
// 32-bit te_ member: test_enum::b
...
...
libcaf_core/test/serialization.cpp
View file @
3d5ddb6e
...
@@ -144,7 +144,6 @@ struct fixture : test_coordinator_fixture<config> {
...
@@ -144,7 +144,6 @@ struct fixture : test_coordinator_fixture<config> {
int64_t
i64
=
-
1234567890123456789ll
;
int64_t
i64
=
-
1234567890123456789ll
;
float
f32
=
3.45
f
;
float
f32
=
3.45
f
;
double
f64
=
54.3
;
double
f64
=
54.3
;
duration
dur
=
duration
{
time_unit
::
seconds
,
123
};
timestamp
ts
=
timestamp
{
timestamp
::
duration
{
1478715821
*
1000000000ll
}};
timestamp
ts
=
timestamp
{
timestamp
::
duration
{
1478715821
*
1000000000ll
}};
test_enum
te
=
test_enum
::
b
;
test_enum
te
=
test_enum
::
b
;
string
str
=
"Lorem ipsum dolor sit amet."
;
string
str
=
"Lorem ipsum dolor sit amet."
;
...
@@ -198,7 +197,7 @@ struct fixture : test_coordinator_fixture<config> {
...
@@ -198,7 +197,7 @@ struct fixture : test_coordinator_fixture<config> {
fixture
()
{
fixture
()
{
rs
.
str
.
assign
(
string
(
str
.
rbegin
(),
str
.
rend
()));
rs
.
str
.
assign
(
string
(
str
.
rbegin
(),
str
.
rend
()));
msg
=
make_message
(
i32
,
i64
,
dur
,
ts
,
te
,
str
,
rs
);
msg
=
make_message
(
i32
,
i64
,
ts
,
te
,
str
,
rs
);
config_value
::
dictionary
dict
;
config_value
::
dictionary
dict
;
put
(
dict
,
"scheduler.policy"
,
atom
(
"none"
));
put
(
dict
,
"scheduler.policy"
,
atom
(
"none"
));
put
(
dict
,
"scheduler.max-threads"
,
42
);
put
(
dict
,
"scheduler.max-threads"
,
42
);
...
@@ -255,7 +254,6 @@ CAF_TEST(serializing and then deserializing produces the same value) {
...
@@ -255,7 +254,6 @@ CAF_TEST(serializing and then deserializing produces the same value) {
CHECK_RT
(
i64
);
CHECK_RT
(
i64
);
CHECK_RT
(
f32
);
CHECK_RT
(
f32
);
CHECK_RT
(
f64
);
CHECK_RT
(
f64
);
CHECK_RT
(
dur
);
CHECK_RT
(
ts
);
CHECK_RT
(
ts
);
CHECK_RT
(
te
);
CHECK_RT
(
te
);
CHECK_RT
(
str
);
CHECK_RT
(
str
);
...
@@ -268,7 +266,6 @@ CAF_TEST(messages serialize and deserialize their content) {
...
@@ -268,7 +266,6 @@ CAF_TEST(messages serialize and deserialize their content) {
CHECK_MSG_RT
(
i64
);
CHECK_MSG_RT
(
i64
);
CHECK_MSG_RT
(
f32
);
CHECK_MSG_RT
(
f32
);
CHECK_MSG_RT
(
f64
);
CHECK_MSG_RT
(
f64
);
CHECK_MSG_RT
(
dur
);
CHECK_MSG_RT
(
ts
);
CHECK_MSG_RT
(
ts
);
CHECK_MSG_RT
(
te
);
CHECK_MSG_RT
(
te
);
CHECK_MSG_RT
(
str
);
CHECK_MSG_RT
(
str
);
...
@@ -321,14 +318,14 @@ CAF_TEST(messages) {
...
@@ -321,14 +318,14 @@ CAF_TEST(messages) {
auto
buf1
=
serialize
(
msg
);
auto
buf1
=
serialize
(
msg
);
deserialize
(
buf1
,
x
);
deserialize
(
buf1
,
x
);
CAF_CHECK_EQUAL
(
to_string
(
msg
),
to_string
(
x
));
CAF_CHECK_EQUAL
(
to_string
(
msg
),
to_string
(
x
));
CAF_CHECK
(
is_message
(
x
).
equal
(
i32
,
i64
,
dur
,
ts
,
te
,
str
,
rs
));
CAF_CHECK
(
is_message
(
x
).
equal
(
i32
,
i64
,
ts
,
te
,
str
,
rs
));
// serialize fully dynamic message again (do another roundtrip)
// serialize fully dynamic message again (do another roundtrip)
message
y
;
message
y
;
auto
buf2
=
serialize
(
x
);
auto
buf2
=
serialize
(
x
);
CAF_CHECK_EQUAL
(
buf1
,
buf2
);
CAF_CHECK_EQUAL
(
buf1
,
buf2
);
deserialize
(
buf2
,
y
);
deserialize
(
buf2
,
y
);
CAF_CHECK_EQUAL
(
to_string
(
msg
),
to_string
(
y
));
CAF_CHECK_EQUAL
(
to_string
(
msg
),
to_string
(
y
));
CAF_CHECK
(
is_message
(
y
).
equal
(
i32
,
i64
,
dur
,
ts
,
te
,
str
,
rs
));
CAF_CHECK
(
is_message
(
y
).
equal
(
i32
,
i64
,
ts
,
te
,
str
,
rs
));
CAF_CHECK_EQUAL
(
to_string
(
recursive
),
to_string
(
roundtrip
(
recursive
)));
CAF_CHECK_EQUAL
(
to_string
(
recursive
),
to_string
(
roundtrip
(
recursive
)));
}
}
...
@@ -342,7 +339,7 @@ CAF_TEST(multiple_messages) {
...
@@ -342,7 +339,7 @@ CAF_TEST(multiple_messages) {
CAF_CHECK_EQUAL
(
std
::
make_tuple
(
t
,
to_string
(
m1
),
to_string
(
m2
)),
CAF_CHECK_EQUAL
(
std
::
make_tuple
(
t
,
to_string
(
m1
),
to_string
(
m2
)),
std
::
make_tuple
(
te
,
to_string
(
m
),
to_string
(
msg
)));
std
::
make_tuple
(
te
,
to_string
(
m
),
to_string
(
msg
)));
CAF_CHECK
(
is_message
(
m1
).
equal
(
rs
,
te
));
CAF_CHECK
(
is_message
(
m1
).
equal
(
rs
,
te
));
CAF_CHECK
(
is_message
(
m2
).
equal
(
i32
,
i64
,
dur
,
ts
,
te
,
str
,
rs
));
CAF_CHECK
(
is_message
(
m2
).
equal
(
i32
,
i64
,
ts
,
te
,
str
,
rs
));
}
}
CAF_TEST
(
type_erased_value
)
{
CAF_TEST
(
type_erased_value
)
{
...
...
libcaf_core/test/simple_timeout.cpp
View file @
3d5ddb6e
...
@@ -75,14 +75,6 @@ timer::behavior_type timer_impl2(timer::pointer self) {
...
@@ -75,14 +75,6 @@ timer::behavior_type timer_impl2(timer::pointer self) {
CAF_TEST_FIXTURE_SCOPE
(
simple_timeout_tests
,
test_coordinator_fixture
<>
)
CAF_TEST_FIXTURE_SCOPE
(
simple_timeout_tests
,
test_coordinator_fixture
<>
)
CAF_TEST
(
duration_conversion
)
{
duration
d1
{
time_unit
::
milliseconds
,
100
};
std
::
chrono
::
milliseconds
d2
{
100
};
duration
d3
{
d2
};
CAF_CHECK_EQUAL
(
d1
.
count
,
static_cast
<
uint64_t
>
(
d2
.
count
()));
CAF_CHECK_EQUAL
(
d1
,
d3
);
}
CAF_TEST
(
single_timeout
)
{
CAF_TEST
(
single_timeout
)
{
sys
.
spawn
(
timer_impl
);
sys
.
spawn
(
timer_impl
);
}
}
...
...
libcaf_io/caf/io/middleman.hpp
View file @
3d5ddb6e
...
@@ -156,7 +156,7 @@ public:
...
@@ -156,7 +156,7 @@ public:
template
<
class
Handle
>
template
<
class
Handle
>
expected
<
Handle
>
expected
<
Handle
>
remote_spawn
(
const
node_id
&
nid
,
std
::
string
name
,
message
args
,
remote_spawn
(
const
node_id
&
nid
,
std
::
string
name
,
message
args
,
duration
timeout
=
duration
(
time_unit
::
minutes
,
1
)
)
{
timespan
timeout
=
timespan
{
60000000000
}
)
{
if
(
!
nid
||
name
.
empty
())
if
(
!
nid
||
name
.
empty
())
return
sec
::
invalid_argument
;
return
sec
::
invalid_argument
;
auto
res
=
remote_spawn_impl
(
nid
,
name
,
args
,
auto
res
=
remote_spawn_impl
(
nid
,
name
,
args
,
...
@@ -172,7 +172,7 @@ public:
...
@@ -172,7 +172,7 @@ public:
remote_spawn
(
const
node_id
&
nid
,
std
::
string
name
,
message
args
,
remote_spawn
(
const
node_id
&
nid
,
std
::
string
name
,
message
args
,
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
)
{
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
)
{
return
remote_spawn
<
Handle
>
(
nid
,
std
::
move
(
name
),
std
::
move
(
args
),
return
remote_spawn
<
Handle
>
(
nid
,
std
::
move
(
name
),
std
::
move
(
args
),
duratio
n
{
timeout
});
timespa
n
{
timeout
});
}
}
/// Smart pointer for `network::multiplexer`.
/// Smart pointer for `network::multiplexer`.
...
@@ -207,7 +207,7 @@ public:
...
@@ -207,7 +207,7 @@ public:
/// Returns a new functor-based broker connected
/// Returns a new functor-based broker connected
/// to `host:port` or an `error`.
/// to `host:port` or an `error`.
/// @warning Blocks the caller for the
duratio
n of the connection process.
/// @warning Blocks the caller for the
timespa
n of the connection process.
template
<
spawn_options
Os
=
no_spawn_options
,
template
<
spawn_options
Os
=
no_spawn_options
,
class
F
=
std
::
function
<
void
(
broker
*
)>,
class
...
Ts
>
class
F
=
std
::
function
<
void
(
broker
*
)>,
class
...
Ts
>
expected
<
typename
infer_handle_from_fun
<
F
>::
type
>
expected
<
typename
infer_handle_from_fun
<
F
>::
type
>
...
@@ -304,7 +304,7 @@ private:
...
@@ -304,7 +304,7 @@ private:
expected
<
strong_actor_ptr
>
expected
<
strong_actor_ptr
>
remote_spawn_impl
(
const
node_id
&
nid
,
std
::
string
&
name
,
message
&
args
,
remote_spawn_impl
(
const
node_id
&
nid
,
std
::
string
&
name
,
message
&
args
,
std
::
set
<
std
::
string
>
s
,
duratio
n
timeout
);
std
::
set
<
std
::
string
>
s
,
timespa
n
timeout
);
expected
<
uint16_t
>
expected
<
uint16_t
>
publish
(
const
strong_actor_ptr
&
whom
,
std
::
set
<
std
::
string
>
sigs
,
publish
(
const
strong_actor_ptr
&
whom
,
std
::
set
<
std
::
string
>
sigs
,
...
...
libcaf_io/src/io/middleman.cpp
View file @
3d5ddb6e
...
@@ -102,7 +102,7 @@ middleman::middleman(actor_system& sys) : system_(sys) {
...
@@ -102,7 +102,7 @@ middleman::middleman(actor_system& sys) : system_(sys) {
expected
<
strong_actor_ptr
>
expected
<
strong_actor_ptr
>
middleman
::
remote_spawn_impl
(
const
node_id
&
nid
,
std
::
string
&
name
,
middleman
::
remote_spawn_impl
(
const
node_id
&
nid
,
std
::
string
&
name
,
message
&
args
,
std
::
set
<
std
::
string
>
s
,
message
&
args
,
std
::
set
<
std
::
string
>
s
,
duratio
n
timeout
)
{
timespa
n
timeout
)
{
auto
f
=
make_function_view
(
actor_handle
(),
timeout
);
auto
f
=
make_function_view
(
actor_handle
(),
timeout
);
return
f
(
spawn_atom
::
value
,
nid
,
std
::
move
(
name
),
std
::
move
(
args
),
return
f
(
spawn_atom
::
value
,
nid
,
std
::
move
(
name
),
std
::
move
(
args
),
std
::
move
(
s
));
std
::
move
(
s
));
...
...
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