[Mono-dev] System.Threading.Thread.ApartmentState Patch

Paolo Molaro lupus at ximian.com
Thu May 3 11:24:50 EDT 2007


On 05/02/07 Jonathan Chambers wrote:
> Index: mono/mono/metadata/threads.c
> ===================================================================
> --- mono/mono/metadata/threads.c	(revision 76569)
> +++ mono/mono/metadata/threads.c	(working copy)
[...]
> +void mono_thread_set_apartment_state ()
> +{

should be:

void
mono_thread_set_apartment_state (void)

It may also be better to name the function mono_thread_apply_apartment_state.

> Index: mono/mono/metadata/object.c
> ===================================================================
> --- mono/mono/metadata/object.c	(revision 76569)
> +++ mono/mono/metadata/object.c	(working copy)
> @@ -2387,6 +2387,7 @@
[...]
> +	cinfo = mono_custom_attrs_from_method (method);
> +	if (cinfo) {
> +		static MonoClass *stathread_attribute = NULL;
> +		MonoThread* thread = mono_thread_current ();
> +		MonoObject* stathread_object;
> +		if (!stathread_attribute)
> +			stathread_attribute = mono_class_from_name (mono_defaults.corlib, "System", "STAThreadAttribute");
> +		mono_custom_attrs_get_attr (cinfo, stathread_attribute);

As zoltan said, use mono_custom_attrs_has_attr().

> Index: mono/mono/metadata/object-internals.h
> ===================================================================
> --- mono/mono/metadata/object-internals.h	(revision 76569)
> +++ mono/mono/metadata/object-internals.h	(working copy)
> @@ -274,7 +274,7 @@
>  	MonoBoolean thread_dump_requested;
>  	gpointer end_stack; /* This is only used when running in the debugger. */
>  	MonoBoolean thread_interrupt_requested;
> -	gpointer unused4;
> +	guint32	apartment_state;

Since you need just 2 bits, please use a guint8 type.

Thanks!

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list