mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-05 22:43:15 +00:00
foreign_ptr: introduce make_local_and_release()
Sometimes remote data has to be copied to local cpu, but if data is already local copy can be avoided. Introduce helper function that moves or copies data depending on origin cpu.
This commit is contained in:
@@ -357,6 +357,17 @@ public:
|
||||
});
|
||||
}
|
||||
}
|
||||
/// release the wrapped object on a local cpu. If executed on cpu
|
||||
/// other than the one object was created on object will be copied
|
||||
/// to local memory.
|
||||
typename std::pointer_traits<PtrType>::element_type make_local_and_release() {
|
||||
if (on_origin()) {
|
||||
return std::move(*_value);
|
||||
} else {
|
||||
// copied to caller's cpu here
|
||||
return *_value;
|
||||
}
|
||||
}
|
||||
/// Accesses the wrapped object.
|
||||
element_type& operator*() const { return *_value; }
|
||||
/// Accesses the wrapped object.
|
||||
|
||||
Reference in New Issue
Block a user