mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +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 {
|
||||
public:
|
||||
virtual ~Disk() {
|
||||
flush_tracks();
|
||||
}
|
||||
virtual ~Disk() {}
|
||||
|
||||
/*!
|
||||
@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) {
|
||||
}
|
||||
|
||||
Drive::~Drive() {
|
||||
if(disk_) disk_->flush_tracks();
|
||||
}
|
||||
|
||||
void Drive::set_disk(const std::shared_ptr<Disk> &disk) {
|
||||
if(disk_) disk_->flush_tracks();
|
||||
disk_ = disk;
|
||||
has_disk_ = !!disk_;
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace Disk {
|
||||
class Drive: public Sleeper, public TimedEventLoop {
|
||||
public:
|
||||
Drive(unsigned int input_clock_rate, int revolutions_per_minute, int number_of_heads);
|
||||
~Drive();
|
||||
|
||||
/*!
|
||||
Replaces whatever is in the drive with @c disk.
|
||||
|
Loading…
x
Reference in New Issue
Block a user