Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1165523
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 07/30] perf tools: Add reference counting for thread_map object |
| Date | 2015-06-15 22:10 +0200 |
| Message-ID | <pBIRI-5m8-13@gated-at.bofh.it> (permalink) |
| References | <pBbsJ-6AA-3@gated-at.bofh.it> <pBbsM-6AA-75@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Em Sun, Jun 14, 2015 at 10:19:22AM +0200, Jiri Olsa escreveu:
> Adding refference counting for thread_map object, so
> it could be easily shared among other objects.
>
> Using thread_map__put instead thread_map__delete and making
> thread_map__delete static.
<SNIP>
> +struct thread_map *thread_map__get(struct thread_map *map)
> +{
> + atomic_inc(&map->refcnt);
> + return map;
> +}
> +
> +void thread_map__put(struct thread_map *map)
> +{
> + if (map && atomic_dec_and_test(&map->refcnt))
> + thread_map__delete(map);
> }
See comment on the other struct being refcounted, get/put should
both accept NULL maps, to avoid having to check it in the users,
just like with free().
- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH 07/30] perf tools: Add reference counting for thread_map object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-15 22:10 +0200
csiph-web