Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Memory exception when actor returns a vector of results#1330

AnsweredbyNeverlord
magersjc asked this question inQ&A
Discussion options

I am currently testing with CAF 0.18.6 and I ran into a strange issue when an actor tries to return a vector of results.
I took the delegating.cpp example in the examples/message_passing folder and changed it as follows:

#include "caf/all.hpp"using namespace caf;CAF_BEGIN_TYPE_ID_BLOCK(caf_custom_types, first_custom_type_id)//CAF_ADD_TYPE_ID(caf_custom_types, (std::vector<int32_t>))//CAF_END_TYPE_ID_BLOCK(caf_custom_types)// --(rst-delegate-begin)--using adder_actor = typed_actor<result<std::vector<int32_t>>(add_atom, int32_t, int32_t)>;adder_actor::behavior_type worker_impl() {   return {     [](add_atom, int32_t x, int32_t y) { std::vector<int32_t> result{}; result.push_back(x + y);  return result; },   };}adder_actor::behavior_type server_impl(adder_actor::pointer self,   adder_actor worker) {   return {     [=](add_atom add, int32_t x, int32_t y) {       return self->delegate(worker, add, x, y);     },   };}void client_impl(event_based_actor* self, adder_actor adder, int32_t x,   int32_t y) {   using namespace std::literals::chrono_literals;   self->request(adder, 10s, add_atom_v, x, y).then([=](std::vector<int32_t> result) {      aout(self) << x << " + " << y << " = " << result[0] << std::endl;      });}void caf_main(actor_system& sys) {   auto worker = sys.spawn(worker_impl);   auto server = sys.spawn(server_impl, sys.spawn(worker_impl));   sys.spawn(client_impl, server, 1, 2);}// --(rst-delegate-end)--CAF_MAIN()

When I run this code I get the following exception :

image

I am compiling with VS2019.

What is causing this and how do we build actors that can return vectors?

Thanks.

You must be logged in to vote

Look like you are missing the initialization of the meta objects table:

CAF_MAIN(id_block:: caf_custom_types)

Replies: 1 comment 1 reply

Comment options

Look like you are missing the initialization of the meta objects table:

CAF_MAIN(id_block:: caf_custom_types)
You must be logged in to vote
1 reply
@magersjc
Comment options

Thanks!! I was hoping it was something simple that I just overlooked, and it was :)

Answer selected bymagersjc
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@magersjc@Neverlord

[8]ページ先頭

©2009-2025 Movatter.jp