From 7d3e2bd2c4cfd1296d1d6f996d7548de26540d41 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Fri, 15 Feb 2013 16:27:18 -0800 Subject: Sync with 8 months of Google-internal development. Many things have changed and been simplified. The memory-management story for upb_def and upb_handlers is much more robust; upb_def and upb_handlers should be fairly stable interfaces now. There is still much work to do for the runtime component (upb_sink). --- upb/refcount.h | 73 ---------------------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 upb/refcount.h (limited to 'upb/refcount.h') diff --git a/upb/refcount.h b/upb/refcount.h deleted file mode 100644 index 91ad3b8..0000000 --- a/upb/refcount.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * upb - a minimalist implementation of protocol buffers. - * - * Copyright (c) 2009 Google Inc. See LICENSE for details. - * Author: Josh Haberman - * - * A thread-safe refcount that can optionally track references for debugging - * purposes. It helps avoid circular references by allowing a - * strongly-connected component in the graph to share a refcount. - * - * This interface is internal to upb. - */ - -#ifndef UPB_REFCOUNT_H_ -#define UPB_REFCOUNT_H_ - -#include -#include -#include "upb/table.h" - -#ifndef NDEBUG -#define UPB_DEBUG_REFS -#endif - -typedef struct _upb_refcount { - uint32_t *count; - struct _upb_refcount *next; // Circularly-linked list of this SCC. - uint16_t index; // For SCC algorithm. - uint16_t lowlink; // For SCC algorithm. -#ifdef UPB_DEBUG_REFS - // Make this a pointer so that we can modify it inside of const methods - // without ugly casts. - upb_inttable *refs; -#endif -} upb_refcount; - -// NON THREAD SAFE operations ////////////////////////////////////////////////// - -// Initializes the refcount with a single ref for the given owner. Returns -// NULL if memory could not be allocated. -bool upb_refcount_init(upb_refcount *r, const void *owner); - -// Uninitializes the refcount. May only be called after unref() returns true. -void upb_refcount_uninit(upb_refcount *r); - -// Finds strongly-connected components among some set of objects and merges all -// refcounts that share a SCC. The given function will be called when the -// algorithm needs to visit children of a particular object; the function -// should call upb_refcount_visit() once for each child obj. -// -// Returns false if memory allocation failed. -typedef void upb_getsuccessors(upb_refcount *obj, void*); -bool upb_refcount_findscc(upb_refcount **objs, int n, upb_getsuccessors *func); -void upb_refcount_visit(upb_refcount *obj, upb_refcount *subobj, void *closure); - -// Thread-safe operations ////////////////////////////////////////////////////// - -// Increases the ref count, the new ref is owned by "owner" which must not -// already own a ref. Circular reference chains are not allowed. -void upb_refcount_ref(const upb_refcount *r, const void *owner); - -// Release a ref owned by owner, returns true if that was the last ref. -bool upb_refcount_unref(const upb_refcount *r, const void *owner); - -// Moves an existing ref from ref_donor to new_owner, without changing the -// overall ref count. -void upb_refcount_donateref( - const upb_refcount *r, const void *from, const void *to); - -// Returns true if these two objects share a refcount. -bool upb_refcount_merged(const upb_refcount *r, const upb_refcount *r2); - -#endif // UPB_REFCOUNT_H_ -- cgit v1.2.3