-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailbox.h
More file actions
24 lines (19 loc) · 728 Bytes
/
Copy pathmailbox.h
File metadata and controls
24 lines (19 loc) · 728 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
// mailbox.h - shared inbox for the student. The two spawners (Professor
// and Friend) push messages; the student pops one at a time and drains.
// All three modules are attached to the same Runtime, so the mailbox
// only ever sees the pump thread and needs no locking.
#pragma once
#include "globals.h"
#include <cstddef>
#include <functional>
class Mailbox
{
public:
static void Push(const Message& m);
static bool TryPop(Message& out);
static std::size_t Size();
// Walk the inbox front-to-back without popping. Used by the viz step
// (on the same pump thread) to snapshot the queue.
static void ForEach(const std::function<void(const Message&)>& fn);
Mailbox() = delete;
};