14 namespace duds {
namespace hardware {
namespace interface {
22 std::unique_lock<std::mutex> lock(
block);
55 std::lock_guard<std::mutex> lock(
block);
99 std::unique_lock<std::mutex> lock(
block);
103 return std::unique_ptr<ChipAccess>(
112 std::unique_lock<std::mutex> lock(
block);
116 acc.
manager = shared_from_this();
121 std::unique_ptr<ChipAccess> ca =
access(chipId);
void changeChip(int chipId)
Changes the chip in use while continuing to use an existing access object.
int waiting
A count of the threads waiting to access chips.
void retire(ChipAccess *ca)
Called by ChipAccess::~ChipAccess() to indicate that the access object is no longer in use...
ChipAccess * curacc
The currently in use access object, or nullptr.
A ChipAccess object was given to ChipSelectManager::access(ChipAccess &, int) that is already providi...
boost::error_info< struct Info_ChipId, int > ChipSelectIdError
The chip select ID relavent to the error.
An attempt was made to retire a ChipAccess object that was not the active access object for the manag...
virtual void deselect()=0
Deselects the chip identified by cid.
virtual void select()=0
Selects the chip identified by cid.
An error indicating an attempt to use an already destructed object.
std::mutex block
Used to synchonize access.
An object used to provide chip select control to a single user at a time.
void baseAccess(std::unique_lock< std::mutex > &lock, int chipId)
Obtains the resources for providing an access object, but does not make an access object...
int cid
Selected chip ID, or -1 to terminate.
friend class ChipAccess
The access object calls select(), deselect(), and retire(ChipAccess *).
std::unique_ptr< ChipAccess > access(int chipId)
Acquires access to the requested chip and issues a ChipAccess object.
std::condition_variable selwait
Used to awaken threads waiting on a chip select.
Indicates an attempt to select a non-existant chip.
virtual bool validChip(int chipId) const noexcept=0
Returns true if chipId references a valid chip for this manager.
virtual ~ChipSelectManager()=0
Derived non-abstract classes must call shutdown() in thier destructor.
#define DUDS_THROW_EXCEPTION(x)
Works like BOOST_THROW_EXCEPTION, but includes a stack trace if DUDS_ERRORS_VERBOSE is defined...
void shutdown()
Waits on a ChipAccess object if one is in use, then begins forcing any threads waiting on access to w...
std::shared_ptr< ChipSelectManager > manager
The manager to which this object is attached.