- Get a basic overview of Nim
- Nim by Examplee
- Made a small contribution, woot!
- Nim Notes
- Nim by Examplee
- modules & imports
- understand
import std/[terminal]
syntax
- understand
- threading & concurrency model(s)
- dependency management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<std::derived_from<Actor> RefOf> | |
class ActorRef { /* ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename RefOf> | |
class ActorRef { | |
std::shared_ptr<RefOf> m_actor; | |
public: | |
ActorRef(std::shared_ptr<RefOf> actor) | |
: m_actor(actor) {} | |
template<typename Message> | |
void send(Message&& msg) { /* TODO */ } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
std::unique_ptr<Actor> actor = std::make_unique<HelloActor>("Howdy"); | |
actor->enqueue([&actor]() { | |
// how do I get it to the correct receiver? | |
dynamic_cast<HelloBehavior*>(actor.get())->receive("neighbor"); | |
}); | |
actor->process_message(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Actor { | |
std::deque<std::function<void()>> m_messages; | |
public: | |
virtual ~Actor() = default; | |
void enqueue(std::function<void()> const& func) { | |
m_messages.push_back(func); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloActor | |
: Actor<std::string> | |
, HelloBehavior { ... } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename ... Messages> | |
class Actor { | |
std::vector<std::variant<Messages ...>> m_messages; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloBehavior { | |
public: | |
virtual void receive(std::string const& msg) = 0; | |
}; | |
class HelloActor | |
: public Actor | |
, public HelloBehavior { | |
std::string m_greeting; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Actor { | |
public: | |
virtual ~Actor() = default; | |
}; | |
class Behavior {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloActor : public Actor { | |
std::string m_greeting; | |
public: | |
HelloActor(std::string const& greeting): m_greeting(greeting){}; | |
void receive(std::string const& msg) { | |
std::cout << m_greeting << " " << msg << "\n"; | |
} | |
}; |
NewerOlder