## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Dmitriy Inyutin
Yes, they are used, now let's see an example, thanks
newjames1988
@newjames1988
Hi, I am new to CAF. i want to use it for my simulator project. I want to control the execution order of the node. is it possible to control execution order of node ?
Dominik Charousset
@Neverlord
What do you mean by execution order? Messages on an actor or what actors run in which order?
newjames1988
@newjames1988
actor run order
Dominik Charousset
@Neverlord
newjames1988
@newjames1988
Dominik Charousset
@Neverlord
So, you want an update from all sensors before calculating the next output?
newjames1988
@newjames1988
Yes
one reason is as follows. My architecture is that one Node will be one Actor. Each node simulation of that part of a robot. Like dynamic behaviour will generate the data, which will fed into another sensor modelling and henceforth. Some sensor output frequency is not the same as others for that time step not to run that Node but use its previous data . We cannot run any control algorithm before getting the data from the sensor.
Dominik Charousset
@Neverlord
If each block is one actor, then I would recommend simply waiting in the ControlAlgo actor until it has all inputs available. Either by simply waiting for three messages or by looking at the sender for each message (this way, a sensor that triggers twice for whatever reason could 'override' its previous input and wouldn't be mistaken for the input for another sensor).
There is a deterministic scheduler in CAF, but you'd throw away all concurrency in your system and it's very easy to shoot yourself in the foot with that (it's mostly meant for unit testing).
Since the sensors trigger at different rates, the most simple solution would be having something like map<strong_actor_ptr, value_type> and run the algorithm whenever you have three entries after receiving something (and override the entry for the sender otherwise).
newjames1988
@newjames1988
simply waiting for three messages or by looking at the sender for each message (this way, a sensor that triggers twice for whatever reason could 'override' its previous input and wouldn't be mistaken for the input for another sensor). I will try to use this .
Dylan Baros
@dylan-baros
Good morning. Is there anyone here who could assist with a windows install? I run cmake .. in the build folder and the project files are all built in the root directory. I then go to the root directory and run cmake --build . and everything seems to build but If I try to run any of the examples .exe files they can't find any of the dlls.
Dominik Charousset
@Neverlord
I suppose you figured it out yourself? actor-framework/actor-framework#1354 :)
If you don't want to deal with shared libraries in the first place and prefer statically linked binaries, you can set --disable-shared-libs (configure script) or BUILD_SHARED_LIBS=OFF (CMake).
Dylan Baros
@dylan-baros
@Neverlord yes thanks. I have never played with windows libraries before but figured out.
Marco Leclerc
@ke9
Hi all, need some help/clarification regarding message_priority before I fill an issue in github. Let's say I send a bunch of high priority messages to an actor, and then a normal priority message... is it by design that a normal priority message will be processed before all high priority messages already in the actor's mailbox? From the documentation: "Urgent messages are put into a different queue of the receiver’s mailbox", I would expect that all queued high priority messages be processed before any new messages are sent to an actor. It used to work in the past (don't remember how long ago), some of our unit tests are failing now with CAF 0.18.5 . thanks for any help/hints !
Dominik Charousset
@Neverlord
@ke9 Actors draw from both queues. They first check the high-priority queue and consume messages up to a maximum. Then they look into the default queue, again consuming up to a maximum of messages. Rince and repeat. Actors will consume more messages from their high-priority queue overall, but the reasoning here is to avoid scenarios where an actor would make no progress at all on its regular messages for a long time if there's a burst of high-priority messages coming in.
Marco Leclerc
@ke9

@Neverlord Hi thanks for the clarification, makes sense to give actor the chance to process all messages, we do the same at a higher level. We will adapt our design accordingly. Would be interesting to document this behavior a little bit in the user manual. On my test (windows box, x64 release) , I send a bunch of high priority messages, then a bunch of normal priority messages and the actor eventually processes 9 high priority messages for 3 normal priority messages (3 to 1 ratio), until the test finishes.
caf::message_priority::high : 1444419
caf::message_priority::normal : 3
caf::message_priority::high : 9
caf::message_priority::normal : 3
caf::message_priority::high : 9
caf::message_priority::normal : 3
caf::message_priority::high : 9
caf::message_priority::normal : 3

Have a nice day!

Dominik Charousset
@Neverlord
Yeah, the docs should definitely mention that! Have nice day as well. 🙂
Dylan Baros
@dylan-baros

I am having an issue where my project builds on linux but does not build on Windows with cmake. Here is the error:

[main] Building folder: POC
[build] Starting build
[proc] Executing command: C:\src\vcpkg\downloads\tools\cmake-3.24.0-windows\cmake-3.24.0-windows-i386\bin\cmake.EXE --build c:/Users/dbaros/Documents/POC_example/POC/build --config Debug --target ALL_BUILD -j 6 --
[build] MSBuild version 17.3.1+2badb37d1 for .NET Framework
[build] duck_classes.vcxproj -> C:\Users\dbaros\Documents\POC_example\POC\build\source\DuckClasses\Debug\duck_classes.lib
[build] libcaf_core.vcxproj -> C:\Users\dbaros\Documents\POC_example\POC\build_deps\caf-build\libcaf_core\Debug\caf_core.lib
[build] main.cpp
[build] C:\Users\dbaros\Documents\POC_example\POC\build_deps\caf-src\libcaf_core\caf/mixin/sender.hpp(73,19): error C2338: static_assert failed: 'at least one type has no ID, did you forgot to announce it via CAF_ADD_TYPE_ID?' [C:\Users\dbaros\Documents\POC_example\POC\build\source\DuckParty\DuckParty.exe.vcxproj]
[build] C:\Users\dbaros\Documents\POC_example\POC\source\DuckParty/DuckActor.h(32): message : see reference to function template instantiation 'void caf::mixin::sender<B,D>::send<caf::message_priority::normal,DisplayActor,const display_behavior&,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<std::chrono::system_clock::rep,std::chrono::system_clock::period>>&,std::string&>(const Dest &,const display_behavior &,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<std::chrono::system_clock::rep,std::chrono::system_clock::period>> &,std::string &)' being compiled [C:\Users\dbaros\Documents\POC_example\POC\build\source\DuckParty\DuckParty.exe.vcxproj]
[build] with
[build] [
[build] B=caf::scheduled_actor,
[build] D=caf::typed_event_based_actor<caf::result<void> (do_duck_behavior)>,
[build] Dest=DisplayActor
[build] ]
[build] C:\Users\dbaros\Documents\POC_example\POC\source\DuckParty/DuckActor.h(32): message : see reference to function template instantiation 'void caf::mixin::sender<B,D>::send<caf::message_priority::normal,DisplayActor,const display_behavior&,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<std::chrono::system_clock::rep,std::chrono::system_clock::period>>&,std::string&>(const Dest &,const display_behavior &,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<std::chrono::system_clock::rep,std::chrono::system_clock::period>> &,std::string &)' being compiled [C:\Users\dbaros\Documents\POC_example\POC\build\source\DuckParty\DuckParty.exe.vcxproj]
[build] with
[build] [
[build] B=caf::scheduled_actor,
[build] D=caf::typed_event_based_actor<caf::result<void> (do_duck_behavior)>,
[build] Dest=DisplayActor
[build] ]
[proc] The command: C:\src\vcpkg\downloads\tools\cmake-3.24.0-windows\cmake-3.24.0-windows-i386\bin\cmake.EXE --build c:/Users/dbaros/Documents/POC_example/POC/build --config Debug --target ALL_BUILD -j 6 -- exited with code: 1 and signal: null
[build] Build finished with exit code 1

Any help would be appreciated
I give the types IDs and it works on linux.
Dominik Charousset
@Neverlord

There's not enough context to tell what's going wrong on MSVC. The static assert usually triggers when forgetting some includes, but that wouldn't explain why it worked for you on Linux.

Btw, if you're evaluating CAF on Windows: there's a performance issue that's been fixed recently actor-framework/actor-framework#1343.

Dylan Baros
@dylan-baros
@Neverlord thanks. So this is likely an include issue? Is there a difference between how the includes are handled on linux and windows?
Dominik Charousset
@Neverlord
It usually is a matter of not having the type ID block visible, but hard to tell without code.
Dylan Baros
@dylan-baros
I inherited this code so pardon my ignorance, but here is what they did, They used CAF_ADD_ATOM:
CAF_BEGIN_TYPE_ID_BLOCK(duck_msg_types, caf::first_custom_type_id)
CAF_END_TYPE_ID_BLOCK(duck_msg_types)
Dylan Baros
@dylan-baros
@Neverlord I did not realize that you actually have seen this code before. I work at National Instruments where you have provided some support for a CAF based project. I posted my repo and question on stackoverflow and if you get a chance to look at it I would appreciate it. https://stackoverflow.com/questions/73901792/cant-compile-code-using-the-c-actor-framework-on-windows-using-cmake-works-o
patszt
@patszt

What is the proper syntax to pass std::vector<std::string> CLI arguments in 0.18.6?

--some-list-option=[\"a\"]

seems to work, but when i try to add the second entry
--some-list-option=[\"a\", \"b\"]
it fails with pec::invalid_argument.

This syntax is used in test/config_option_set.cpp

Used to work with just --some-list-option=a,b in 0.17.6
Dominik Charousset
@Neverlord
@dylan-baros I'll take a look over the weekend.
@patszt On the shell, you often have the problem that the shell is eating up the quotes. Did you try passing something like my_app '--my-list=["a", "b"]'?
(note the single quotes around the whole --my-list argument)
Alexander Gagarin
@uentity
@Neverlord what's the expected timeframe for CAF 0.19 release?
Dominik Charousset
@Neverlord
@uentity working on the last major feature as we speak. :)
Plan is to release the first RC end of october.
Alexander Gagarin
@uentity
nice )
Dominik Charousset
@Neverlord
If you wanna keep track: https://github.com/actor-framework/actor-framework/milestone/18. #1347 is the last "big" feature.
Alexander Gagarin
@uentity
thanks for info!
Dominik Charousset
@Neverlord
Don't mention it. Sorry for the delay, originally, we've targeted mid-2022 for 0.19. But, you know how it is.. ;)
Alexander Gagarin
@uentity
@Neverlord perfectly know ) and you did amazing amount of work
Dominik Charousset
@Neverlord
Much appreciated, but it's not just me. 🙂
Even if most commits come from me at the moment, it wouldn't happen without discussions, feedback and testing from others that happens "behind the scenes".
Alexander Gagarin
@uentity
of cause, credits to all the team ) I see a lot of new API and useful features like websockets, etc. Fingers crossed it will be documented or described in articles =)
Dominik Charousset
@Neverlord
Yeah, the best feature is worth nothing without documentation. 😄
patszt
@patszt

@dylan-baros I'll take a look over the weekend.
@patszt On the shell, you often have the problem that the shell is eating up the quotes. Did you try passing something like my_app '--my-list=["a", "b"]'?

This works :) Thanks

Dominik Charousset
@Neverlord
👍
patszt
@patszt
void foo(typed_actor parent) {
auto spawned = parent->spawn(new_actor);
parent->request(std::move(spawned), int{5}).then([]{});
}
is such function legal? It seems to me that the spawned actor may die and "then" will never be called. Is the lifetime somehow preserved here or are my worries justified?
Dominik Charousset
@Neverlord
The spawned actor won't terminate as long as there are still references to it. And it has a reference as long as it has messages in its mailbox. So this is fine.
patszt
@patszt
What if the request returns a not delivered promise? So we create a response_promise in the only message the spawned received. The response_promise is part of spawned state and we return it to response handle. Is the ref_count now 2? What happens to the response_handle once we exit this scope?
Dominik Charousset
@Neverlord
I don't understand what you are trying to say with "not delivered promise". The promises are actor-local and must not be visible outside of an actor. If an actor terminates before it fulfills a promise, it'll trigger a broken promise error message.
patszt
@patszt
Okay so the promise cannot be returned from the message handler?
But generally the request to spawned is supposed to create response_promise -> request to other actors- > deliver the promise once all actors respond to previous requests