[Mesa-stable] [PATCH] clover: Add support to mem objects for multiple destructor callbacks v2

Francisco Jerez currojerez at riseup.net
Mon Sep 22 09:19:30 PDT 2014


Thanks, looks good to me,

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

Tom Stellard <thomas.stellard at amd.com> writes:

> The spec says that mem objects should maintain a stack of callbacks
> not just one.
>
> v2:
>   - Remove stray printf.
>
> CC: "10.3" <mesa-stable at lists.freedesktop.org>
> ---
>  src/gallium/state_trackers/clover/core/memory.cpp | 10 ++++++----
>  src/gallium/state_trackers/clover/core/memory.hpp |  3 ++-
>  2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/core/memory.cpp b/src/gallium/state_trackers/clover/core/memory.cpp
> index ba6869d..905ebc0 100644
> --- a/src/gallium/state_trackers/clover/core/memory.cpp
> +++ b/src/gallium/state_trackers/clover/core/memory.cpp
> @@ -29,14 +29,16 @@ using namespace clover;
>  memory_obj::memory_obj(clover::context &ctx, cl_mem_flags flags,
>                         size_t size, void *host_ptr) :
>     context(ctx), _flags(flags),
> -   _size(size), _host_ptr(host_ptr),
> -   _destroy_notify([]{}) {
> +   _size(size), _host_ptr(host_ptr) {
>     if (flags & (CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR))
>        data.append((char *)host_ptr, size);
>  }
>  
>  memory_obj::~memory_obj() {
> -   _destroy_notify();
> +   while (_destroy_notify.size()) {
> +      _destroy_notify.top()();
> +      _destroy_notify.pop();
> +   }
>  }
>  
>  bool
> @@ -46,7 +48,7 @@ memory_obj::operator==(const memory_obj &obj) const {
>  
>  void
>  memory_obj::destroy_notify(std::function<void ()> f) {
> -   _destroy_notify = f;
> +   _destroy_notify.push(f);
>  }
>  
>  cl_mem_flags
> diff --git a/src/gallium/state_trackers/clover/core/memory.hpp b/src/gallium/state_trackers/clover/core/memory.hpp
> index f649ca0..bd6da6b 100644
> --- a/src/gallium/state_trackers/clover/core/memory.hpp
> +++ b/src/gallium/state_trackers/clover/core/memory.hpp
> @@ -26,6 +26,7 @@
>  #include <functional>
>  #include <map>
>  #include <memory>
> +#include <stack>
>  
>  #include "core/object.hpp"
>  #include "core/queue.hpp"
> @@ -61,7 +62,7 @@ namespace clover {
>        cl_mem_flags _flags;
>        size_t _size;
>        void *_host_ptr;
> -      std::function<void ()> _destroy_notify;
> +      std::stack<std::function<void ()>> _destroy_notify;
>  
>     protected:
>        std::string data;
> -- 
> 1.8.5.5
>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-stable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-stable/attachments/20140922/4e557585/attachment.sig>


More information about the mesa-stable mailing list