locked
IMetaDataAssemblyEmit/IMetaDataEmit - thread safety

    Question

  • Are the IMetaDataAssemblyEmit/IMetaDataEmit interfaces thread safe when obtained via the ICorProfilerCallback::GetModuleMetaData(...) call?

    The only information I can find regarding "thread safety" ... as it relates to these interfaces ... comes from documentation on IMetaDataDispenserEx::SetOption() --- http://msdn.microsoft.com/en-us/library/ms231869(v=vs.100).aspx

    The documentation states that setting the option MetaDataThreadSafetyOptions  --- "Controls whether the metadata engine obtains reader/writer locks, thereby ensuring thread safety. By default, the engine assumes that access is single-threaded by the caller, so no locks are obtained. Clients are responsible for maintaining proper thread synchronization when using the metadata API."

    The question then is what is the behavior of the metadata engine when the interfaces are obtained via the ICorProfilerCallback::GetModuleMetaData(...) call?

    Thanks for the help/clarification!

    Dave

    Thursday, December 13, 2012 8:21 PM

Answers

  • Hi, Dave.

    I'm not completely sure and don't have the code in front of me to verify.  But generally this shouldn't matter, as your edits should happen in ModuleLoadFinished only, in which case synchronization is not an issue (only one thread can be in MLF for a given module at a time).  The exception to this rule is adding localvarsigtokens, which is allowed after module load is complete, and while jitting or rejitting is occurring.  I'll need to double-check on that scenario.

    Thanks,
    Dave

    Thursday, December 27, 2012 2:26 PM
    Owner

All replies

  • Hi Dave,

    Welcome to the MSDN Forum.

    I am trying to involve some other one into this case, wait it patiently, please.

    Thank you.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 14, 2012 6:49 AM
    Moderator
  • Hi, Dave.

    I'm not completely sure and don't have the code in front of me to verify.  But generally this shouldn't matter, as your edits should happen in ModuleLoadFinished only, in which case synchronization is not an issue (only one thread can be in MLF for a given module at a time).  The exception to this rule is adding localvarsigtokens, which is allowed after module load is complete, and while jitting or rejitting is occurring.  I'll need to double-check on that scenario.

    Thanks,
    Dave

    Thursday, December 27, 2012 2:26 PM
    Owner