Skip to content

♻ VDML Refactor #22

@SizzinSeal

Description

@SizzinSeal

Overview

The VDML (AKA Vex Data Management Layer) ensures thread safety when interacting with devices from multiple threads. However, the decision to write it in C was a poor design choice. It should be written in C++ to avoid the use of macros.

Motivation

Maintaining device implementations is unnecessarily difficult currently.

Potential Implementation

// vdml.cpp
#include "vdml.hpp"

namespace vdml {

static constinit std::array<std::mutex, 21> array;

std::mutex& get_smart_port_mutex(uint8_t port) {
    return array.at(port - 1);
}

} // namespace vdml
// motor.cpp
#include "Motor.hpp"
#include "vdml.hpp"

namespace zest {

void Motor::move(double power) {
    const std::lock_guard lock(vdml::get_smart_port_mutex(m_port));
    // ...
}

} // namespace zest

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    in progressthis issue is currently being worked on

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions