Files
dolphin/Source/Core/Core/HW/GCMemcardRaw.h
Shawn Hoffman 44a1a7cdbe move the decision to delay raw memcard flushes out of the thread.
This allows the flush to work better with games which hammer
memcard accesses over short periods as it delays more of the work.
2014-09-01 22:38:31 -07:00

41 lines
1.0 KiB
C++

// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include <chrono>
#include <memory>
#include "Common/Event.h"
#include "Common/Flag.h"
#include "Common/Thread.h"
#include "Core/HW/GCMemcard.h"
class PointerWrap;
class MemoryCard : public MemoryCardBase
{
public:
MemoryCard(std::string filename, int _card_index, u16 sizeMb = MemCard2043Mb);
~MemoryCard();
void FlushThread();
void TryFlush();
s32 Read(u32 address, s32 length, u8 *destaddress) override;
s32 Write(u32 destaddress, s32 length, u8 *srcaddress) override;
void ClearBlock(u32 address) override;
void ClearAll() override;
void DoState(PointerWrap &p) override;
private:
std::string m_filename;
std::unique_ptr<u8[]> m_memcard_data;
std::thread m_flush_thread;
std::mutex m_flush_mutex;
Common::Event m_flush_trigger;
Common::Flag m_is_exiting;
std::unique_ptr<u8[]> m_flush_buffer;
std::chrono::steady_clock::time_point m_last_flush;
static const std::chrono::seconds s_flush_interval;
};