Experimenting with xdb API, starting on compare tool.
This commit is contained in:
@@ -249,7 +249,6 @@ int Translate_SOURCE_OFFSET(TranslationContext& ctx, Instr* i) {
|
||||
|
||||
// TODO(benvanik): dispatch of register forms.
|
||||
uint32_t IntCode_TRACE_SOURCE(IntCodeState& ics, const IntCode* i) {
|
||||
// TODO(benvanik): append to active trace writer.
|
||||
uint64_t trace_base = ics.thread_state->memory()->trace_base();
|
||||
if (trace_base) {
|
||||
auto ev = xdb::protocol::InstrEvent::Append(trace_base);
|
||||
@@ -323,7 +322,7 @@ uint32_t IntCode_TRAP(IntCodeState& ics, const IntCode* i) {
|
||||
switch (i->flags) {
|
||||
case 20:
|
||||
// 0x0FE00014 is a 'debug print' where r3 = buffer r4 = length
|
||||
break;
|
||||
return IA_NEXT;
|
||||
case 22:
|
||||
// Always trap?
|
||||
break;
|
||||
|
||||
@@ -20,6 +20,9 @@ namespace alloy {
|
||||
|
||||
// TODO(benvanik): go lockfree, and don't hold the lock while emitting.
|
||||
|
||||
template <typename T>
|
||||
class Delegate;
|
||||
|
||||
template <typename T>
|
||||
class Delegate {
|
||||
public:
|
||||
@@ -30,16 +33,6 @@ class Delegate {
|
||||
listeners_.push_back(listener);
|
||||
}
|
||||
|
||||
void RemoveListener(Listener const& listener) {
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
for (auto it = listeners_.begin(); it != listeners_.end(); ++it) {
|
||||
if (it == listener) {
|
||||
listeners_.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveAllListeners() {
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
listeners_.clear();
|
||||
@@ -57,6 +50,33 @@ class Delegate {
|
||||
std::vector<Listener> listeners_;
|
||||
};
|
||||
|
||||
template <>
|
||||
class Delegate<void> {
|
||||
public:
|
||||
typedef std::function<void()> Listener;
|
||||
|
||||
void AddListener(Listener const& listener) {
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
listeners_.push_back(listener);
|
||||
}
|
||||
|
||||
void RemoveAllListeners() {
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
listeners_.clear();
|
||||
}
|
||||
|
||||
void operator()() {
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
for (auto& listener : listeners_) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex lock_;
|
||||
std::vector<Listener> listeners_;
|
||||
};
|
||||
|
||||
} // namespace alloy
|
||||
|
||||
#endif // ALLOY_DELEGATE_H_
|
||||
|
||||
Reference in New Issue
Block a user