Improve ToggleRef release overhead.
Candidate patch provided by Andres in pull request #17. * glib/Object.cs: use ToggleRef.Dispose. * glib/ToggleRef.cs: implement IDisposable and expose former Free functionality as Dispose(). Free is now private non-lock taking called by Dispose and the idle queue handler.
This commit is contained in:
parent
10f4f03943
commit
4f42fb77fb
2 changed files with 9 additions and 5 deletions
|
@ -69,7 +69,7 @@ namespace GLib {
|
|||
return;
|
||||
|
||||
if (disposing)
|
||||
tref.Free ();
|
||||
tref.Dispose ();
|
||||
else
|
||||
tref.QueueUnref ();
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ namespace GLib {
|
|||
if (handle != IntPtr.Zero) {
|
||||
Objects.Remove (handle);
|
||||
if (tref != null) {
|
||||
tref.Free ();
|
||||
tref.Dispose ();
|
||||
tref = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace GLib {
|
||||
|
||||
internal class ToggleRef {
|
||||
internal class ToggleRef : IDisposable {
|
||||
|
||||
bool hardened;
|
||||
IntPtr handle;
|
||||
|
@ -57,12 +57,16 @@ namespace GLib {
|
|||
}
|
||||
}
|
||||
|
||||
public void Free ()
|
||||
{
|
||||
public void Dispose ()
|
||||
{
|
||||
lock (PendingDestroys) {
|
||||
PendingDestroys.Remove (this);
|
||||
}
|
||||
Free ();
|
||||
}
|
||||
|
||||
void Free ()
|
||||
{
|
||||
if (hardened)
|
||||
g_object_unref (handle);
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue