Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Jun 27, 2023
1 parent dcb079d commit fdafcab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,27 @@ type Hidden_Table_Registry
Registry (reference_counter : HiddenTableReferenceCounter)

## PRIVATE
Creates a new reference to the table with the given name.

Once this and any other references to this table name are garbage
collected, the table will be scheduled for disposal and removed on the
next `run_maintenance_table_cleanup` invocation (unless the table is
'brought back to life' by new references being introduced).
make_reference : Text -> Managed_Resource
make_reference self table_name =
self.reference_counter.increment table_name
reference = Hidden_Table_Reference.Reference self table_name
Managed_Resource.register reference dispose_reference

## PRIVATE
Lists all tables that were added to the registry by calling
`make_reference` and not yet removed.
list_hidden_tables : Vector Text
list_hidden_tables self =
Vector.from_polyglot_array self.reference_counter.getKnownTables

## PRIVATE
Checks if the given table name is registered in the registry.
is_registered : Text -> Boolean
is_registered self table_name =
self.reference_counter.isRegistered table_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ type From_Spec_Comparator
_ -> Default_Comparator.compare x y

## PRIVATE
hash x = Default_Comparator.hash x
hash x = case x of
From_Spec.Table table_name _ _ ->
Default_Comparator.hash table_name
_ -> Default_Comparator.hash x

Comparable.from (_ : From_Spec) = From_Spec_Comparator
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public synchronized void decrement(String name) {
});
}

/**
* Checks if the given table name is currently present in the registry.
*
* <p>A table is 'registered' even if its reference count has dropped to zero, as long as it has
* not been disposed yet.
*/
public synchronized boolean isRegistered(String name) {
return tableRefCounts.containsKey(name);
}
Expand Down

0 comments on commit fdafcab

Please sign in to comment.