|
@@ -95,13 +95,12 @@ unsafe fn from_iterator<T: Sized>(
|
|
|
Some(region)
|
|
Some(region)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-pub struct CheckResponsesPtr<'a> {
|
|
|
|
|
|
|
+pub struct CheckResponsesPtr {
|
|
|
ptr: NonNull<CheckResponse>,
|
|
ptr: NonNull<CheckResponse>,
|
|
|
count: usize,
|
|
count: usize,
|
|
|
- allocator: &'a Allocator,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-impl<'a> CheckResponsesPtr<'a> {
|
|
|
|
|
|
|
+impl CheckResponsesPtr {
|
|
|
/// Constructs the pointer from a [`TransactionResponseRegion`].
|
|
/// Constructs the pointer from a [`TransactionResponseRegion`].
|
|
|
///
|
|
///
|
|
|
/// # Safety
|
|
/// # Safety
|
|
@@ -109,10 +108,9 @@ impl<'a> CheckResponsesPtr<'a> {
|
|
|
/// - The provided [`TransactionResponseRegion`] must be of type
|
|
/// - The provided [`TransactionResponseRegion`] must be of type
|
|
|
/// [`worker_message_types::CHECK_RESPONSE`].
|
|
/// [`worker_message_types::CHECK_RESPONSE`].
|
|
|
/// - The allocation pointed to by this region must not have previously been freed.
|
|
/// - The allocation pointed to by this region must not have previously been freed.
|
|
|
- /// - Pointer must be exclusive so that calling [`Self::free`] is safe.
|
|
|
|
|
pub unsafe fn from_transaction_response_region(
|
|
pub unsafe fn from_transaction_response_region(
|
|
|
transaction_response_region: &TransactionResponseRegion,
|
|
transaction_response_region: &TransactionResponseRegion,
|
|
|
- allocator: &'a Allocator,
|
|
|
|
|
|
|
+ allocator: &Allocator,
|
|
|
) -> Self {
|
|
) -> Self {
|
|
|
debug_assert!(transaction_response_region.tag == worker_message_types::CHECK_RESPONSE);
|
|
debug_assert!(transaction_response_region.tag == worker_message_types::CHECK_RESPONSE);
|
|
|
|
|
|
|
@@ -121,7 +119,6 @@ impl<'a> CheckResponsesPtr<'a> {
|
|
|
.ptr_from_offset(transaction_response_region.transaction_responses_offset)
|
|
.ptr_from_offset(transaction_response_region.transaction_responses_offset)
|
|
|
.cast(),
|
|
.cast(),
|
|
|
count: transaction_response_region.num_transaction_responses as usize,
|
|
count: transaction_response_region.num_transaction_responses as usize,
|
|
|
- allocator,
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -141,18 +138,21 @@ impl<'a> CheckResponsesPtr<'a> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// Free the batch's allocation.
|
|
/// Free the batch's allocation.
|
|
|
- pub fn free(self) {
|
|
|
|
|
- unsafe { self.allocator.free(self.ptr.cast()) }
|
|
|
|
|
|
|
+ ///
|
|
|
|
|
+ /// # Safety
|
|
|
|
|
+ ///
|
|
|
|
|
+ /// - `Self` must be exclusively owned.
|
|
|
|
|
+ pub unsafe fn free(self, allocator: &Allocator) {
|
|
|
|
|
+ unsafe { allocator.free(self.ptr.cast()) }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-pub struct ExecutionResponsesPtr<'a> {
|
|
|
|
|
|
|
+pub struct ExecutionResponsesPtr {
|
|
|
ptr: NonNull<ExecutionResponse>,
|
|
ptr: NonNull<ExecutionResponse>,
|
|
|
count: usize,
|
|
count: usize,
|
|
|
- allocator: &'a Allocator,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-impl<'a> ExecutionResponsesPtr<'a> {
|
|
|
|
|
|
|
+impl ExecutionResponsesPtr {
|
|
|
/// Constructs the pointer from a [`TransactionResponseRegion`].
|
|
/// Constructs the pointer from a [`TransactionResponseRegion`].
|
|
|
///
|
|
///
|
|
|
/// # Safety
|
|
/// # Safety
|
|
@@ -160,10 +160,9 @@ impl<'a> ExecutionResponsesPtr<'a> {
|
|
|
/// - The provided [`TransactionResponseRegion`] must be of type
|
|
/// - The provided [`TransactionResponseRegion`] must be of type
|
|
|
/// [`worker_message_types::EXECUTION_RESPONSE`].
|
|
/// [`worker_message_types::EXECUTION_RESPONSE`].
|
|
|
/// - The allocation pointed to by this region must not have previously been freed.
|
|
/// - The allocation pointed to by this region must not have previously been freed.
|
|
|
- /// - Pointer must be exclusive so that calling [`Self::free`] is safe.
|
|
|
|
|
pub unsafe fn from_transaction_response_region(
|
|
pub unsafe fn from_transaction_response_region(
|
|
|
transaction_response_region: &TransactionResponseRegion,
|
|
transaction_response_region: &TransactionResponseRegion,
|
|
|
- allocator: &'a Allocator,
|
|
|
|
|
|
|
+ allocator: &Allocator,
|
|
|
) -> Self {
|
|
) -> Self {
|
|
|
debug_assert!(transaction_response_region.tag == worker_message_types::EXECUTION_RESPONSE);
|
|
debug_assert!(transaction_response_region.tag == worker_message_types::EXECUTION_RESPONSE);
|
|
|
|
|
|
|
@@ -172,7 +171,6 @@ impl<'a> ExecutionResponsesPtr<'a> {
|
|
|
.ptr_from_offset(transaction_response_region.transaction_responses_offset)
|
|
.ptr_from_offset(transaction_response_region.transaction_responses_offset)
|
|
|
.cast(),
|
|
.cast(),
|
|
|
count: transaction_response_region.num_transaction_responses as usize,
|
|
count: transaction_response_region.num_transaction_responses as usize,
|
|
|
- allocator,
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -192,7 +190,11 @@ impl<'a> ExecutionResponsesPtr<'a> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// Free the batch's allocation.
|
|
/// Free the batch's allocation.
|
|
|
- pub fn free(self) {
|
|
|
|
|
- unsafe { self.allocator.free(self.ptr.cast()) }
|
|
|
|
|
|
|
+ ///
|
|
|
|
|
+ /// # Safety
|
|
|
|
|
+ ///
|
|
|
|
|
+ /// - `Self` must be exclusively owned.
|
|
|
|
|
+ pub unsafe fn free(self, allocator: &Allocator) {
|
|
|
|
|
+ unsafe { allocator.free(self.ptr.cast()) }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|