Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Latest commit

 

History

History
History
61 lines (50 loc) · 1.21 KB

File metadata and controls

61 lines (50 loc) · 1.21 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: BSD-3-Clause
/*
A registry of global arrays.
Each array has a globally unique id.
*/
#include "sharpy/Registry.hpp"
#include <mutex>
#include <unordered_map>
namespace SHARPY {
namespace Registry {
using locker = std::lock_guard<std::mutex>;
using keeper_type =
std::unordered_map<id_type, array_i::future_type>; //::weak_type>;
static keeper_type _keeper;
static std::mutex _mutex;
static id_type _nguid = -1;
id_type get_guid() { return ++_nguid; }
void put(const array_i::future_type &ptr) {
locker _l(_mutex);
_keeper.insert({ptr.guid(), ptr});
}
bool has(id_type id) {
locker _l(_mutex);
return _keeper.find(id) != _keeper.end();
}
array_i::future_type get(id_type id) {
locker _l(_mutex);
auto x = _keeper.find(id);
if (x == _keeper.end())
throw(std::runtime_error("Encountered request for unknown array."));
return x->second; //.lock();
}
void del(id_type id) {
locker _l(_mutex);
_keeper.erase(id);
}
std::vector<id_type> get_all() {
std::vector<id_type> res;
locker _l(_mutex);
for (auto f : _keeper) {
res.emplace_back(f.first);
}
return res;
}
void fini() {
locker _l(_mutex);
_keeper.clear();
}
} // namespace Registry
} // namespace SHARPY
Morty Proxy This is a proxified and sanitized view of the page, visit original site.