-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailbox.h
More file actions
25 lines (20 loc) · 707 Bytes
/
Copy pathmailbox.h
File metadata and controls
25 lines (20 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// mailbox.h - FIFO that the sender enqueues into and the receiver
// drains. Sender + receiver both live on the same Runtime, so the
// mailbox is touched only by one pump thread; the mutex exists only
// because the viz step (also on the pump thread) and snapshots are
// read on the main thread elsewhere.
#pragma once
#include "globals.h"
#include <deque>
#include <vector>
class Mailbox
{
public:
static void Push(const Msg& m);
static bool TryPop(Msg& out);
static std::size_t Size();
// Snapshot the queued items for the visualisation. Called on the
// pump thread; the caller copies the result into g_snap.
static std::vector<Msg> Snapshot();
Mailbox() = delete;
};