---
title: llarp::EventLoop

---

# llarp::EventLoop





Inherited by [llarp::uv::Loop](Classes/classllarp_1_1uv_1_1Loop.md)

## Public Types

|                | Name           |
| -------------- | -------------- |
| using std::function< void([UDPHandle](Classes/structllarp_1_1UDPHandle.md) &, [SockAddr](Classes/structllarp_1_1SockAddr.md) src, [llarp::OwnedBuffer](Classes/structllarp_1_1OwnedBuffer.md) buf)> | **[UDPReceiveFunc](Classes/classllarp_1_1EventLoop.md#using-udpreceivefunc)**  |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| virtual void | **[run](Classes/classllarp_1_1EventLoop.md#function-run)**() =0 |
| virtual bool | **[running](Classes/classllarp_1_1EventLoop.md#function-running)**() const =0 |
| virtual llarp_time_t | **[time_now](Classes/classllarp_1_1EventLoop.md#function-time-now)**() const =0 |
| template <typename Callable \> <br>void | **[call](Classes/classllarp_1_1EventLoop.md#function-call)**(Callable && f) |
| virtual void | **[call_soon](Classes/classllarp_1_1EventLoop.md#function-call-soon)**(std::function< void(void)> f) =0 |
| virtual void | **[call_later](Classes/classllarp_1_1EventLoop.md#function-call-later)**(llarp_time_t delay_ms, std::function< void(void)> callback) =0 |
| template <typename Callable \> <br>void | **[call_every](Classes/classllarp_1_1EventLoop.md#function-call-every)**(llarp_time_t repeat, std::weak_ptr< void > owner, Callable f) |
| template <typename Callable \> <br>auto | **[make_caller](Classes/classllarp_1_1EventLoop.md#function-make-caller)**(Callable f) |
| virtual bool | **[add_network_interface](Classes/classllarp_1_1EventLoop.md#function-add-network-interface)**(std::shared_ptr< [vpn::NetworkInterface](Classes/classllarp_1_1vpn_1_1NetworkInterface.md) > netif, std::function< void([net::IPPacket](Classes/structllarp_1_1net_1_1IPPacket.md))> packetHandler) =0 |
| virtual bool | **[add_ticker](Classes/classllarp_1_1EventLoop.md#function-add-ticker)**(std::function< void(void)> ticker) =0 |
| virtual void | **[stop](Classes/classllarp_1_1EventLoop.md#function-stop)**() =0 |
| virtual | **[~EventLoop](Classes/classllarp_1_1EventLoop.md#function-~eventloop)**() =default |
| virtual const [net::Platform](Classes/classllarp_1_1net_1_1Platform.md) * | **[Net_ptr](Classes/classllarp_1_1EventLoop.md#function-net-ptr)**() const |
| virtual std::shared_ptr< [UDPHandle](Classes/structllarp_1_1UDPHandle.md) > | **[make_udp](Classes/classllarp_1_1EventLoop.md#function-make-udp)**(UDPReceiveFunc on_recv) =0 |
| virtual std::shared_ptr< [EventLoopWakeup](Classes/classllarp_1_1EventLoopWakeup.md) > | **[make_waker](Classes/classllarp_1_1EventLoop.md#function-make-waker)**(std::function< void()> callback) =0<br>Make a thread-safe event loop waker (an "async" in libuv terminology) on this event loop; you can call `->Trigger()` on the returned shared pointer to fire the callback at the next available event loop iteration.  |
| virtual std::shared_ptr< [EventLoopRepeater](Classes/classllarp_1_1EventLoopRepeater.md) > | **[make_repeater](Classes/classllarp_1_1EventLoop.md#function-make-repeater)**() =0 |
| virtual bool | **[inEventLoop](Classes/classllarp_1_1EventLoop.md#function-ineventloop)**() const =0 |
| virtual std::shared_ptr< uvw::Loop > | **[MaybeGetUVWLoop](Classes/classllarp_1_1EventLoop.md#function-maybegetuvwloop)**() |
| virtual void | **[wakeup](Classes/classllarp_1_1EventLoop.md#function-wakeup)**() =0 |
| std::shared_ptr< [EventLoop](Classes/classllarp_1_1EventLoop.md) > | **[create](Classes/classllarp_1_1EventLoop.md#function-create)**(size_t queueLength =[event_loop_queue_size](Namespaces/namespacellarp.md#variable-event-loop-queue-size)) |

## Public Types Documentation

### using UDPReceiveFunc

```cpp
using llarp::EventLoop::UDPReceiveFunc =  std::function<void(UDPHandle&, SockAddr src, llarp::OwnedBuffer buf)>;
```


## Public Functions Documentation

### function run

```cpp
virtual void run() =0
```


**Reimplemented by**: [llarp::uv::Loop::run](Classes/classllarp_1_1uv_1_1Loop.md#function-run)


### function running

```cpp
virtual bool running() const =0
```


**Reimplemented by**: [llarp::uv::Loop::running](Classes/classllarp_1_1uv_1_1Loop.md#function-running)


### function time_now

```cpp
virtual llarp_time_t time_now() const =0
```


**Reimplemented by**: [llarp::uv::Loop::time_now](Classes/classllarp_1_1uv_1_1Loop.md#function-time-now)


### function call

```cpp
template <typename Callable >
inline void call(
    Callable && f
)
```


### function call_soon

```cpp
virtual void call_soon(
    std::function< void(void)> f
) =0
```


**Reimplemented by**: [llarp::uv::Loop::call_soon](Classes/classllarp_1_1uv_1_1Loop.md#function-call-soon)


### function call_later

```cpp
virtual void call_later(
    llarp_time_t delay_ms,
    std::function< void(void)> callback
) =0
```


**Reimplemented by**: [llarp::uv::Loop::call_later](Classes/classllarp_1_1uv_1_1Loop.md#function-call-later)


### function call_every

```cpp
template <typename Callable >
inline void call_every(
    llarp_time_t repeat,
    std::weak_ptr< void > owner,
    Callable f
)
```


### function make_caller

```cpp
template <typename Callable >
inline auto make_caller(
    Callable f
)
```


### function add_network_interface

```cpp
virtual bool add_network_interface(
    std::shared_ptr< vpn::NetworkInterface > netif,
    std::function< void(net::IPPacket)> packetHandler
) =0
```


### function add_ticker

```cpp
virtual bool add_ticker(
    std::function< void(void)> ticker
) =0
```


**Reimplemented by**: [llarp::uv::Loop::add_ticker](Classes/classllarp_1_1uv_1_1Loop.md#function-add-ticker)


### function stop

```cpp
virtual void stop() =0
```


**Reimplemented by**: [llarp::uv::Loop::stop](Classes/classllarp_1_1uv_1_1Loop.md#function-stop)


### function ~EventLoop

```cpp
virtual ~EventLoop() =default
```


### function Net_ptr

```cpp
virtual const net::Platform * Net_ptr() const
```


### function make_udp

```cpp
virtual std::shared_ptr< UDPHandle > make_udp(
    UDPReceiveFunc on_recv
) =0
```


**Reimplemented by**: [llarp::uv::Loop::make_udp](Classes/classllarp_1_1uv_1_1Loop.md#function-make-udp)


### function make_waker

```cpp
virtual std::shared_ptr< EventLoopWakeup > make_waker(
    std::function< void()> callback
) =0
```

Make a thread-safe event loop waker (an "async" in libuv terminology) on this event loop; you can call `->Trigger()` on the returned shared pointer to fire the callback at the next available event loop iteration. 

**Reimplemented by**: [llarp::uv::Loop::make_waker](Classes/classllarp_1_1uv_1_1Loop.md#function-make-waker)


(Multiple Trigger calls invoked before the call is actually made are coalesced into one call). 


### function make_repeater

```cpp
virtual std::shared_ptr< EventLoopRepeater > make_repeater() =0
```


**Reimplemented by**: [llarp::uv::Loop::make_repeater](Classes/classllarp_1_1uv_1_1Loop.md#function-make-repeater)


### function inEventLoop

```cpp
virtual bool inEventLoop() const =0
```


**Reimplemented by**: [llarp::uv::Loop::inEventLoop](Classes/classllarp_1_1uv_1_1Loop.md#function-ineventloop)


### function MaybeGetUVWLoop

```cpp
inline virtual std::shared_ptr< uvw::Loop > MaybeGetUVWLoop()
```


**Reimplemented by**: [llarp::uv::Loop::MaybeGetUVWLoop](Classes/classllarp_1_1uv_1_1Loop.md#function-maybegetuvwloop)


### function wakeup

```cpp
virtual void wakeup() =0
```


**Reimplemented by**: [llarp::uv::Loop::wakeup](Classes/classllarp_1_1uv_1_1Loop.md#function-wakeup)


### function create

```cpp
static std::shared_ptr< EventLoop > create(
    size_t queueLength =event_loop_queue_size
)
```


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

Updated on 2023-01-30 at 17:55:37 +0000