Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/c8b403250fc5...12cdbfceb768
Commit: 248c37dfa9e724c5b007711819487f5859beacea
Author: Rodrigo Kumpera <[email protected]> (kumpera)
Date: 2013-10-25 15:40:51 GMT
URL: https://github.com/mono/mono/commit/248c37dfa9e724c5b007711819487f5859beacea
[runtime] Promote the reference queue API to the public.
Changed paths:
M mono/metadata/gc-internal.h
M mono/metadata/object.h
Modified: mono/metadata/gc-internal.h
===================================================================
@@ -335,9 +335,6 @@
FILE *mono_gc_get_logfile (void) MONO_INTERNAL;
-typedef void (*mono_reference_queue_callback) (void *user_data);
-
-typedef struct _MonoReferenceQueue MonoReferenceQueue;
typedef struct _RefQueueEntry RefQueueEntry;
struct _RefQueueEntry {
@@ -355,10 +352,6 @@ struct _MonoReferenceQueue {
gboolean should_be_deleted;
};
-MonoReferenceQueue* mono_gc_reference_queue_new (mono_reference_queue_callback callback) MONO_INTERNAL;
-void mono_gc_reference_queue_free (MonoReferenceQueue *queue) MONO_INTERNAL;
-gboolean mono_gc_reference_queue_add (MonoReferenceQueue *queue, MonoObject *obj, void *user_data) MONO_INTERNAL;
-
#ifdef HOST_WIN32
BOOL APIENTRY mono_gc_dllmain (HMODULE module_handle, DWORD reason, LPVOID reserved) MONO_INTERNAL;
#endif
Modified: mono/metadata/object.h
===================================================================
@@ -311,6 +311,24 @@
MONO_API MonoObject* mono_gchandle_get_target (uint32_t gchandle);
MONO_API void mono_gchandle_free (uint32_t gchandle);
+/* Reference queue support
+ *
+ * A reference queue is used to get notifications of when objects are collected.
+ * Call mono_gc_reference_queue_new to create a new queue and pass the callback that
+ * will be invoked when registered objects are collected.
+ * Call mono_gc_reference_queue_add to register a pair of objects and data within a queue.
+ * The callback will be triggered once an object is both unreachable and finalized.
+ */
+
+typedef void (*mono_reference_queue_callback) (void *user_data);
+typedef struct _MonoReferenceQueue MonoReferenceQueue;
+
+MONO_API MonoReferenceQueue* mono_gc_reference_queue_new (mono_reference_queue_callback callback);
+MONO_API void mono_gc_reference_queue_free (MonoReferenceQueue *queue);
+MONO_API mono_bool mono_gc_reference_queue_add (MonoReferenceQueue *queue, MonoObject *obj, void *user_data);
+
+
+
/* GC write barriers support */
MONO_API void mono_gc_wbarrier_set_field (MonoObject *obj, void* field_ptr, MonoObject* value);
MONO_API void mono_gc_wbarrier_set_arrayref (MonoArray *arr, void* slot_ptr, MonoObject* value);
Commit: 12cdbfceb7681d76fd024c7fd634ebedbfbd1c18
Author: Rodrigo Kumpera <[email protected]> (kumpera)
Date: 2013-10-25 15:41:08 GMT
URL: https://github.com/mono/mono/commit/12cdbfceb7681d76fd024c7fd634ebedbfbd1c18
[runtime] Improve the docs on reference queues a bit.
Changed paths:
M mono/metadata/gc.c
Modified: mono/metadata/gc.c
===================================================================
@@ -1473,16 +1473,20 @@ void mono_gc_cleanup (void)
}
/**
* mono_gc_reference_queue_new:
- * @callback callback used when processing dead entries.
+ * @callback callback used when processing collected entries.
*
* Create a new reference queue used to process collected objects.
- * A reference queue let you queue a pair (managed object, user data)
+ * A reference queue let you add a pair of (managed object, user data)
* using the mono_gc_reference_queue_add method.
*
* Once the managed object is collected @callback will be called
* in the finalizer thread with 'user data' as argument.
*
- * The callback is called without any locks held.
+ * The callback is called from the finalizer thread without any locks held.
+ * When a AppDomain is unloaded, all callbacks for objects belonging to it
+ * will be invoked.
+ *
+ * @returns the new queue.
*/
MonoReferenceQueue*
mono_gc_reference_queue_new (mono_reference_queue_callback callback)
@@ -1506,7 +1510,7 @@ void mono_gc_cleanup (void)
*
* Queue an object to be watched for collection, when the @obj is
* collected, the callback that was registered for the @queue will
- * be invoked with the @obj and @user_data arguments.
+ * be invoked with @user_data as argument.
*
* @returns false if the queue is scheduled to be freed.
*/
@@ -1534,9 +1538,9 @@ void mono_gc_cleanup (void)
/**
* mono_gc_reference_queue_free:
- * @queue the queue that should be deleted.
+ * @queue the queue that should be freed.
*
- * This operation signals that @queue should be deleted. This operation is deferred
+ * This operation signals that @queue should be freed. This operation is deferred
* as it happens on the finalizer thread.
*
* After this call, no further objects can be queued. It's the responsibility of the
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.