Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Dominik Charousset
@Neverlord
Are you running a scoped actor inside an event-based actor?
Farafonov Alexey
@farafonov-alexey

Are you running a scoped actor inside an event-based actor?

No, we have some regular class which do this in order to communicate with actor-world.

Dominik Charousset
@Neverlord
Hm. If you can reproduce some kind of hanging even with just calling the constructor of scoped_actor, then I don't see what might cause this in CAF itself. The constructor has no blocking code in it: https://github.com/actor-framework/actor-framework/blob/master/libcaf_core/src/scoped_actor.cpp#L41. Unless it has something to do with other factors in your application, the only thing that might block is the logger if it gets overwhelmed with log messages because it's using a fixed-size buffer (precisely to slow down an application if logs too fast for the logger to keep up). But for you to wait several seconds in this call, you would have produce tons and tons of log messages in another thread.
Cem Degirmenci
@sputnikcem_twitter
is it possible to use a scoped_actor to request the proxy of a remote actor as in distributed_calculator.cpp?
in distributed_calculator.cpp a stateful actor is used for this purpose
I get something like invalid use of 'void'
image.png
Dominik Charousset
@Neverlord
Whether you're using a scoped actor doesn't matter for the MM actor. What's the error?
Cem Degirmenci
@sputnikcem_twitter
image.png
I don't know where the void comes from actually
Dominik Charousset
@Neverlord
It's generally more helpful to paste the error into chat using markdown blocks. :)
Hard to tell without the full context what's wrong here. The self->request(...).receive(...) part LGTM tho: https://github.com/actor-framework/actor-framework/blob/master/examples/message_passing/request.cpp#L65.
Cem Degirmenci
@sputnikcem_twitter
I will test with this function thank you
Cem Degirmenci
@sputnikcem_twitter
I get : error: static assertion failed: receiver does not accept given message if I try to use this code block
Dominik Charousset
@Neverlord
The middleman actor does not accept a get message. The code was meant as an example on how scoped actors use request().receiveI(), I didn't want you to just paste that code into your source file.
Cem Degirmenci
@sputnikcem_twitter
ok casting port to uint16_t was necessary
thank you :D
Dominik Charousset
@Neverlord
Complaining about void was a bit misleading, then... Oh well, that's C++ compiler errors for you. Glad you figured it out. :)
Cem Degirmenci
@sputnikcem_twitter
I have one more question, if I receive pointer of a typed_actor from the middleman, which has std::set<std::string>& ifs non empty, how should I use the actor cast?
I mean I get a strong_actor_ptr but how can I cast it to a typed actor for sending a message?
Dominik Charousset
@Neverlord

You can use the run-time-type information to check whether a cast to your target type is safe. Basically:

system. message_types<Handle>() gives you the expected set: https://github.com/actor-framework/actor-framework/blob/master/libcaf_core/caf/actor_system.hpp#L250.
Then you can ask whether you can assign something you've received to the what you're expecting: https://github.com/actor-framework/actor-framework/blob/master/libcaf_core/caf/actor_system.hpp#L261.

If system.assignable(what_we_received, what_we_expect) return true, you can go ahead and actor_cast the strong pointer to your handle and be assured it's safe.
Pierre-Henri LE FUR
@phlf_gitlab

Hello, I am trying to get acquainted with the actor model using CAF and I have a few questions in mind (not related to each others):

  • Can actors be used for building some sort of parallel task engine like what naughty dog did (using actors instead of fibers)
  • I understand that CAF can make use of a work stealing scheduling algorithm which implies queues. Just out of curiosity, would implementing a pattern like the LMAX disruptor for CAF's queues mechanism provide any performance benefits?
  • Does any one know any good general reference regarding the actor model outside of CAF manual and doc?

Thank you for your time

Dominik Charousset
@Neverlord

Fibers are usually used to build co-routine like abstractions. It's just at a lower abstraction level than actors. You can just spawn actors and assign tasks to them, but you won't have much control over what runs when. If all you need is a bunch of workers doing things in the background that's fine. If you're designing a game engine and need very tight control over the scheduling than you probably need a different solution like the one naughty dog was building.

LMAX disruptors: you neder know until you try and benchmark. :)

I don't have a particular article or talk I could recommend for the actor model in general, but at least for CAF there are some articles available online that should be better suited for learning aspects of the framework than manual/docs: https://www.cafcademy.com/articles.

Pierre-Henri LE FUR
@phlf_gitlab

Thank you @Neverlord

You can just spawn actors and assign tasks to them, but you won't have much control over what runs when

Does CAF provides an API for defining priorities in its scheduler? I know that the actor model is supposed to be asynchronous but as there is an experimental streaming API in CAF is it possible to have some control over a pipeline latency similar to what GStreamer provides?

If you're designing a game engine and need very tight control over the scheduling than you probably need a different solution like the one naughty dog was building.

I saw that Novaquark is using CAF for their game engine. I would be very curious to know how they use it, but I bet they won't disclose it anytime soon ;)

I know... just so many questions (please excuse me)

Dominik Charousset
@Neverlord

Does CAF provides an API for defining priorities in its scheduler?

No. Also, if you're starting new code I wouldn't recommend the current streaming API since we're currently working on a complete redesign that's going to look a. lot more like ReactiveX-style APIs (https://twitter.com/actor_framework/status/1390192103200759810). But even there, the model is asynchronous and "runs eventually". If you have actors that should stay responsive at all times, you can detach them, i.e., give them their own thread of execution.

I saw that Novaquark is using CAF for their game engine. I would be very curious to know how they use it

Yeah, they probably won't exactly share their sources.. :)

Pierre-Henri LE FUR
@phlf_gitlab
That's very clear. Thank you @Neverlord
Quang Huy Nguyen
@Qhuy1605_twitter

Hi, i'm installing CAF on Ubuntu 20.10. When I try to run the configure file, then the following error occurs:

-- The CXX compiler identification is GNU 10.2.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/CMakeLists.txt:373 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory
"/home/student/Desktop/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/libcaf_core"
is not a subdirectory of
"/home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master".
When specifying an out-of-tree source a binary directory must be explicitly
specified.

CMake Error at /home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/CMakeLists.txt:376 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory
"/home/student/Desktop/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/libcaf_io"
is not a subdirectory of
"/home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master".
When specifying an out-of-tree source a binary directory must be explicitly
specified.

CMake Error at /home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/CMakeLists.txt:380 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory
"/home/student/Desktop/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/libcaf_openssl"
is not a subdirectory of
"/home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master".
When specifying an out-of-tree source a binary directory must be explicitly
specified.

CMake Error at /home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/CMakeLists.txt:384 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory
"/home/student/Desktop/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/examples"
is not a subdirectory of
"/home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master".
When specifying an out-of-tree source a binary directory must be explicitly
specified.

CMake Error at /home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/CMakeLists.txt:388 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory
"/home/student/Desktop/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master/tools"
is not a subdirectory of
"/home/student/Desktop/student/Desktop/student/Desktop/student/Downloads/actor-framework-master".
When specifying an out-of-tree source a binary directory must be explicitly
specified.

-- Configuring incomplete, errors occurred!
See also "/home/student/Desktop/student/Downloads/actor-framework-master/build/CMakeFiles/CMakeOutput.log".

The path of caf source code is; /home/student/Desktop/student/Downloads/actor-framework-master. Is something missing in my configuration? Thank you in advance!

Cem Degirmenci
@sputnikcem_twitter
did you do ./configure --prefix=$PWD/build in the beginning?
Farafonov Alexey
@farafonov-alexey

Hello all. What is the proper syntax of this 0.17 block

self->attach_functor([=](const caf::error& reason) {
    if (reason.category() == atom_constant<atom("exit")>::value) {
    ...

in caf 0.18?

Dominik Charousset
@Neverlord
category gives you a type ID in 0.18, so you'd need to compare against the ID of the atom. Something like reason.category() == type_id_v<my_atom>.
Farafonov Alexey
@farafonov-alexey
Well I think this exit atom was inner caf.
type_id_v<exit>?
Dominik Charousset
@Neverlord
Isn't this code supposed to check whether the error is an exit_reason?
Then that'd be just category() == type_id_v<exit_reason>.
Farafonov Alexey
@farafonov-alexey
That's code snippet inside caf 0.17 broker, where we trying to determing caf::error category in attach_functor and do smth if this is exit

Isn't this code supposed to check whether the error is an exit_reason?

Yes. Thank you!

Dominik Charousset
@Neverlord
👍
Farafonov Alexey
@farafonov-alexey
Get this compile error. Couldn't find out what is wrong. I'm not using caf::byte btw.
[build] ...MSVC\14.28.29333\include\xmemory(701,82): error C2440: 'initializing': cannot convert from 'const caf::byte' to '_Objty'
[build]           with
[build]           [
[build]               _Objty=unsigned char
[build]           ]
Farafonov Alexey
@farafonov-alexey
Figured out the cause of error new_data_msg.buf has custom type byte_buffer, that is vector of caf::byte
Quang Huy Nguyen
@Qhuy1605_twitter

did you do ./configure --prefix=$PWD/build in the beginning?

Hi, i have tried but this error still occurs :(

Dominik Charousset
@Neverlord
Can you share what steps you've taken? Git checkout, configure arguments, etc. The CMake output looks weird, like something messed with the folders.
Dominik Charousset
@Neverlord
Maybe just deleting the build directory and doing a clean build would already help.
Quang Huy Nguyen
@Qhuy1605_twitter

Can you share what steps you've taken? Git checkout, configure arguments, etc. The CMake output looks weird, like something messed with the folders.

Hi Dominik, i just downloaded the source code from git, and ran ./configure without arguments (like the document on git).

Quang Huy Nguyen
@Qhuy1605_twitter
Nevermind, i have already fixed it. Thank you!
ferjif
@ferjif
Hey. I was searching on logging in caf but couldn't find any examples. not even in the examples folder of caf's github. can anyone help me on how to do it
Dominik Charousset
@Neverlord
You basically need to build CAF with logging enabled. Either by passing --log-level=... to the configure script or by setting CAF_LOG_LEVEL directly when using CMake. Maybe this article here is of some use: https://www.cafcademy.com/gems/indenting-trace-logs
Christian C.
@DrDeadbrain
Hey I have a question about Message Handling when using Group Communication. Do all group member have to handle all messages that are published inside the group? At the moment I'm only have returns for messages that I want to handle with the specific group member but I'm getting a lot of unexpected message errors that seem to terminate my members.
If I have to handle every message what is the best way to handle them without publishing a new message to the group?
Thanks in advance
Dominik Charousset
@Neverlord
Yes, all subscribers have to handle all messages on the group. If you respond to a group message, everyone in the groups receives the response. You can either add matching handlers to all subscribers or add a default handler to silently discard messages you didn't expect. But beware of the risk, since doing this can lead to very hard-to-debug errors down the road.
Christian C.
@DrDeadbrain
Alright. Thanks for your fast reply!