mirror of
https://github.com/dart-lang/sdk
synced 2024-07-03 08:19:13 +00:00
[vm/doc] Add examples to WeakReference
and NativeFinalizer
take 2
Change-Id: Iabafdcc45052bf76f4d13e32566149efd8f71adf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243263 Commit-Queue: Michael Thomsen <mit@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Michael Thomsen <mit@google.com>
This commit is contained in:
parent
8c390e55d5
commit
eeb8b3a343
|
@ -93,8 +93,8 @@ class Expando<T extends Object> {
|
|||
/// /// ```
|
||||
/// /// final cached = CachedComputation(
|
||||
/// /// () => jsonDecode(someJsonSource) as Object);
|
||||
/// /// print(cached.result);
|
||||
/// /// print(cached.result);
|
||||
/// /// print(cached.result); // Executes computation.
|
||||
/// /// print(cached.result); // Most likely uses cache.
|
||||
/// /// ```
|
||||
/// class CachedComputation<R extends Object> {
|
||||
/// final R Function() computation;
|
||||
|
@ -164,8 +164,8 @@ abstract class WeakReference<T extends Object> {
|
|||
/// factory Database.connect() {
|
||||
/// // Wraps the connection in a nice user API,
|
||||
/// // *and* closes connection if the user forgets to.
|
||||
/// var connection = DBConnection.connect();
|
||||
/// var wrapper = Database._fromConnection(connection);
|
||||
/// final connection = DBConnection.connect();
|
||||
/// final wrapper = Database._fromConnection(connection);
|
||||
/// // Get finalizer callback when `wrapper` is no longer reachable.
|
||||
/// _finalizer.attach(wrapper, connection, detach: wrapper);
|
||||
/// return wrapper;
|
||||
|
@ -253,8 +253,8 @@ abstract class Finalizer<T> {
|
|||
/// factory Database.connect() {
|
||||
/// // Wraps the connection in a nice user API,
|
||||
/// // *and* closes connection if the user forgets to.
|
||||
/// var connection = DBConnection.connect();
|
||||
/// var wrapper = Database._fromConnection();
|
||||
/// final connection = DBConnection.connect();
|
||||
/// final wrapper = Database._fromConnection();
|
||||
/// // Get finalizer callback when `wrapper` is no longer reachable.
|
||||
/// _finalizer.attach(wrapper, connection, detach: wrapper);
|
||||
/// return wrapper;
|
||||
|
|
Loading…
Reference in New Issue
Block a user