Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

refactor(aio): simplify disk_engine interfaces #528

Merged
merged 5 commits into from
Jul 3, 2020

Conversation

neverchanje
Copy link
Contributor

@neverchanje neverchanje commented Jul 2, 2020

class disk_engine : public utils::singleton<disk_engine>
{
public:
    // asynchronous file read/write
    disk_file *open(const char *file_name, int flag, int pmode);
    error_code close(disk_file *fh);
    error_code flush(disk_file *fh);
    void read(aio_task *aio);

disk_engine was somehow designed as a middle layer between "file_io" API and "aio_provider" API.

For example, file::flush forwards the call to disk_engine::flush, then forwards to aio_provider::flush.

/*extern*/ error_code flush(disk_file *file) { return disk_engine::instance().flush(file); }
error_code disk_engine::flush(disk_file *fh)
{
    if (nullptr != fh) {
        auto df = (disk_file *)fh;
        return _provider->flush(df->native_handle());
    } else {
        return ERR_INVALID_HANDLE;
    }
}

As a middle layer, disk_engine adds complexity of the code but doesn't bring abstraction above aio_provider. So I plan to reduce the functionalities of this class. I may eventually remove this class.

src/core/aio/disk_engine.h Outdated Show resolved Hide resolved
@neverchanje neverchanje merged commit 002eb4b into XiaoMi:master Jul 3, 2020
@neverchanje neverchanje deleted the file_api branch July 3, 2020 06:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants