Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6c293a3d
Commit
6c293a3d
authored
Jan 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/nfs: add more API documentation
parent
e847ddf0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
Callback.hxx
src/lib/nfs/Callback.hxx
+12
-0
FileReader.hxx
src/lib/nfs/FileReader.hxx
+43
-0
No files found.
src/lib/nfs/Callback.hxx
View file @
6c293a3d
...
...
@@ -24,9 +24,21 @@
#include <exception>
/**
* Callbacks for an asynchronous libnfs operation.
*
* Note that no callback is invoked for cancelled operations.
*/
class
NfsCallback
{
public
:
/**
* The operation completed successfully.
*/
virtual
void
OnNfsCallback
(
unsigned
status
,
void
*
data
)
=
0
;
/**
* An error has occurred.
*/
virtual
void
OnNfsError
(
std
::
exception_ptr
&&
e
)
=
0
;
};
...
...
src/lib/nfs/FileReader.hxx
View file @
6c293a3d
...
...
@@ -35,6 +35,14 @@
struct
nfsfh
;
class
NfsConnection
;
/**
* A helper class which helps with reading from a file. It obtains a
* connection lease (#NfsLease), opens the given file, "stats" the
* file, and finally allos you to read its contents.
*
* To get started, derive your class from it and implement the pure
* virtual methods, construct an instance, and call Open().
*/
class
NfsFileReader
:
NfsLease
,
NfsCallback
,
DeferredMonitor
{
enum
class
State
{
INITIAL
,
...
...
@@ -63,14 +71,30 @@ public:
void
DeferClose
();
/**
* Open the file. This method is thread-safe.
*
* Throws std::runtime_error on error.
*/
void
Open
(
const
char
*
uri
);
/**
* Attempt to read from the file. This may only be done after
* OnNfsFileOpen() has been called. Only one read operation
* may be performed at a time.
*
* This method is not thread-safe and must be called from
* within the I/O thread.
*
* Throws std::runtime_error on error.
*/
void
Read
(
uint64_t
offset
,
size_t
size
);
/**
* Cancel the most recent Read() call.
*
* This method is not thread-safe and must be called from
* within the I/O thread.
*/
void
CancelRead
();
bool
IsIdle
()
const
{
...
...
@@ -78,8 +102,27 @@ public:
}
protected
:
/**
* The file has been opened successfully. It is a regular
* file, and its size is known. It is ready to be read from
* using Read().
*
* This method will be called from within the I/O thread.
*/
virtual
void
OnNfsFileOpen
(
uint64_t
size
)
=
0
;
/**
* A Read() has completed successfully.
*
* This method will be called from within the I/O thread.
*/
virtual
void
OnNfsFileRead
(
const
void
*
data
,
size_t
size
)
=
0
;
/**
* An error has occurred, which can be either while waiting
* for OnNfsFileOpen(), or while waiting for OnNfsFileRead(),
* or if disconnected while idle.
*/
virtual
void
OnNfsFileError
(
std
::
exception_ptr
&&
e
)
=
0
;
private
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment