Skip to content

Commit 216c3b9

Browse files
committed
librados: document shallow copy semantics of IoCtx
Signed-off-by: Casey Bodley <[email protected]>
1 parent 3e40916 commit 216c3b9

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/include/rados/librados.hpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ inline namespace v14_2_0 {
202202
int set_complete_callback(void *cb_arg, callback_t cb);
203203
int set_safe_callback(void *cb_arg, callback_t cb)
204204
__attribute__ ((deprecated));
205-
/// Request immediate cancellation with error code -ECANCELED
206-
/// if the operation hasn't already completed.
205+
/// Request immediate cancellation as if by IoCtx::aio_cancel().
207206
int cancel();
208207
int wait_for_complete();
209208
int wait_for_safe() __attribute__ ((deprecated));
@@ -775,17 +774,30 @@ inline namespace v14_2_0 {
775774
void tier_evict();
776775
};
777776

778-
/* IoCtx : This is a context in which we can perform I/O.
779-
* It includes a Pool,
777+
/**
778+
* @brief A handle to a RADOS pool used to perform I/O operations.
780779
*
781780
* Typical use (error checking omitted):
782-
*
781+
* @code
783782
* IoCtx p;
784783
* rados.ioctx_create("my_pool", p);
785-
* p->stat(&stats);
786-
* ... etc ...
784+
* p.stat("my_object", &size, &mtime);
785+
* @endcode
786+
*
787+
* IoCtx holds a pointer to its underlying implementation. The dup()
788+
* method performs a deep copy of this implementation, but the copy
789+
* construction and assignment operations perform shallow copies by
790+
* sharing that pointer.
791+
*
792+
* Function names starting with aio_ are asynchronous operations that
793+
* return immediately after submitting a request, and whose completions
794+
* are managed by the given AioCompletion pointer. The IoCtx's underlying
795+
* implementation is involved in the delivery of these completions, so
796+
* the caller must guarantee that its lifetime is preserved until then -
797+
* if not by preserving the IoCtx instance that submitted the request,
798+
* then by a copied/moved instance that shares the same implementation.
787799
*
788-
* NOTE: be sure to call watch_flush() prior to destroying any IoCtx
800+
* @note Be sure to call watch_flush() prior to destroying any IoCtx
789801
* that is used for watch events to ensure that racing callbacks
790802
* have completed.
791803
*/
@@ -794,9 +806,13 @@ inline namespace v14_2_0 {
794806
public:
795807
IoCtx();
796808
static void from_rados_ioctx_t(rados_ioctx_t p, IoCtx &pool);
809+
/// Construct a shallow copy of rhs, sharing its underlying implementation.
797810
IoCtx(const IoCtx& rhs);
811+
/// Assign a shallow copy of rhs, sharing its underlying implementation.
798812
IoCtx& operator=(const IoCtx& rhs);
813+
/// Move construct from rhs, transferring its underlying implementation.
799814
IoCtx(IoCtx&& rhs) noexcept;
815+
/// Move assign from rhs, transferring its underlying implementation.
800816
IoCtx& operator=(IoCtx&& rhs) noexcept;
801817

802818
~IoCtx();
@@ -1153,7 +1169,8 @@ inline namespace v14_2_0 {
11531169
int aio_stat2(const std::string& oid, AioCompletion *c, uint64_t *psize, struct timespec *pts);
11541170

11551171
/**
1156-
* Cancel aio operation
1172+
* Request immediate cancellation with error code -ECANCELED
1173+
* if the operation hasn't already completed.
11571174
*
11581175
* @param c completion handle
11591176
* @returns 0 on success, negative error code on failure

0 commit comments

Comments
 (0)