mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-19 23:29:05 +00:00
Ensures lifetime-linked track flushing without relying on virtual calls within a destructor.
This commit is contained in:
parent
53b99ea248
commit
b37787a414
@ -23,9 +23,7 @@ namespace Disk {
|
|||||||
|
|
||||||
class Disk {
|
class Disk {
|
||||||
public:
|
public:
|
||||||
virtual ~Disk() {
|
virtual ~Disk() {}
|
||||||
flush_tracks();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@returns the number of discrete positions that this disk uses to model its complete surface area.
|
@returns the number of discrete positions that this disk uses to model its complete surface area.
|
||||||
|
@ -21,7 +21,12 @@ Drive::Drive(unsigned int input_clock_rate, int revolutions_per_minute, int numb
|
|||||||
available_heads_(number_of_heads) {
|
available_heads_(number_of_heads) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Drive::~Drive() {
|
||||||
|
if(disk_) disk_->flush_tracks();
|
||||||
|
}
|
||||||
|
|
||||||
void Drive::set_disk(const std::shared_ptr<Disk> &disk) {
|
void Drive::set_disk(const std::shared_ptr<Disk> &disk) {
|
||||||
|
if(disk_) disk_->flush_tracks();
|
||||||
disk_ = disk;
|
disk_ = disk;
|
||||||
has_disk_ = !!disk_;
|
has_disk_ = !!disk_;
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ namespace Disk {
|
|||||||
class Drive: public Sleeper, public TimedEventLoop {
|
class Drive: public Sleeper, public TimedEventLoop {
|
||||||
public:
|
public:
|
||||||
Drive(unsigned int input_clock_rate, int revolutions_per_minute, int number_of_heads);
|
Drive(unsigned int input_clock_rate, int revolutions_per_minute, int number_of_heads);
|
||||||
|
~Drive();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Replaces whatever is in the drive with @c disk.
|
Replaces whatever is in the drive with @c disk.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user