---
title: llarp/context.hpp

---

# llarp/context.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::vpn](Namespaces/namespacellarp_1_1vpn.md)**  |
| **[llarp::thread](Namespaces/namespacellarp_1_1thread.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::RuntimeOptions](Classes/structllarp_1_1RuntimeOptions.md)**  |
| struct | **[llarp::Context](Classes/structllarp_1_1Context.md)**  |




## Source code

```cpp
#ifndef LLARP_HPP
#define LLARP_HPP

#include <future>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <vector>

namespace llarp
{
  namespace vpn
  {
    class Platform;
  }

  class EventLoop;
  struct Config;
  struct RouterContact;
  struct Config;
  struct Crypto;
  struct CryptoManager;
  struct AbstractRouter;
  class NodeDB;

  namespace thread
  {
    class ThreadPool;
  }

  struct RuntimeOptions
  {
    bool showBanner = true;
    bool debug = false;
    bool isSNode = false;
  };

  struct Context
  {
    std::shared_ptr<Crypto> crypto = nullptr;
    std::shared_ptr<CryptoManager> cryptoManager = nullptr;
    std::shared_ptr<AbstractRouter> router = nullptr;
    std::shared_ptr<EventLoop> loop = nullptr;
    std::shared_ptr<NodeDB> nodedb = nullptr;

    Context();
    virtual ~Context() = default;

    void
    Setup(const RuntimeOptions& opts);

    int
    Run(const RuntimeOptions& opts);

    void
    HandleSignal(int sig);

    void
    Configure(std::shared_ptr<Config> conf);

    void
    Reload();

    bool
    IsUp() const;

    bool
    LooksAlive() const;

    bool
    IsStopping() const;

    void
    CloseAsync();

    void
    Wait();

    bool
    CallSafe(std::function<void(void)> f);

    virtual std::shared_ptr<AbstractRouter>
    makeRouter(const std::shared_ptr<EventLoop>& loop);

    virtual std::shared_ptr<NodeDB>
    makeNodeDB();

    virtual std::shared_ptr<llarp::vpn::Platform>
    makeVPNPlatform();

    int androidFD = -1;

   protected:
    std::shared_ptr<Config> config = nullptr;

   private:
    void
    SigINT();
    std::unique_ptr<std::promise<void>> closeWaiter;
  };
}  // namespace llarp

#endif
```


-------------------------------

Updated on 2023-04-27 at 04:17:18 +0000
