Skip to content

Mutex, Queue, SizedQueue and ConditionVariable are Thread::Mutex and so on, as in MRI - #44

Merged
Largo merged 1 commit into
Largo:masterfrom
sholden:fix/thread-class-names
Oct 29, 2026
Merged

Largo merged 1 commit into
Largo:masterfrom
sholden:fix/thread-class-names

Conversation

@sholden

@sholden sholden commented Oct 29, 2026

Copy link
Copy Markdown

The Threading library defined these four classes at the top level, and ruby4.rb then aliased them into Thread. As a result Mutex.name, #inspect and every error message that names the class said Mutex where MRI says Thread::Mutex:

                 MRI                               IronRuby before
Mutex            Thread::Mutex                     Mutex
Queue.new        #<Thread::Queue:0x...>            #<Queue:0x...>
cv.marshal_dump  can't dump Thread::ConditionVariable  can't dump ConditionVariable

The classes are now defined in Thread with DefineIn, and ruby4.rb publishes the top-level Mutex/Queue/SizedQueue/ConditionVariable as aliases, as MRI does. Mutex.equal?(Thread::Mutex) is still true, and reopening class Thread::Mutex or class Mutex reaches the same class.

ClassInitGenerator change

A class defined in an unnamed extension of a CLR type got the CLR name as its prefix: System::Threading::Thread::Mutex. The Threading library's ThreadOps is such an extension. Its other options both fail:

  • Naming it "Thread" turns it into a definition, which can't reopen the builtin Thread at load ("cannot redefine class `Thread'").
  • DefineIn can't point at the builtins' ThreadOps, because the generator only resolves DefineIn within one library.

The generator now uses the top-level Ruby name that another library in the same assembly gives the extended type, here the builtins' [RubyClass("Thread", Extends = typeof(Thread))].

Regenerated Initializers.Generated.cs: the Threading section changes as expected. The only other change is that one Kernel extension's private loader methods are renamed (LoadIronRuby__Builtins__Kernel_* → LoadKernel_*), with no change in behaviour. There's no reordering noise.

RubyQueue.cs changes only in its [RubyClass] attribute line. Queue#pop is being worked on separately.

Testing (Linux, net10.0)

Still different (not in this PR)

  • Marshal.dump(Queue.new) says "no _dump_data is defined for class Thread::Queue". MRI says "can't dump Thread::Queue". That's Queue's own code.
  • UnboundMethod#inspect has no source location (MRI: <internal:thread_sync>:100).

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c8f7213-ed4f-4273-b7d4-d6e56ad1689e
Commits

Reviewing files that changed from the base of the PR and between f1ddae6 and 90f4d02.

Files ignored due to path filters: 1
  • Src/Libraries/Initializers.Generated.cs is excluded by !**/*.generated.*
Files selected for processing: 6
  • Src/ClassInitGenerator/Libraries/LibraryDef.cs
  • Src/Libraries/Thread/RubyConditionVariable.cs
  • Src/Libraries/Thread/RubyMutex.cs
  • Src/Libraries/Thread/RubyQueue.cs
  • Src/Libraries/Thread/SizedQueue.cs
  • Src/StdLib/ironruby/ruby4.rb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…so on, as in MRI

The Threading library defined them at the top level and ruby4.rb aliased them into
Thread, so their name - and with it #inspect, #name and every error message that
names the class - was "Mutex" where MRI says "Thread::Mutex". They are now defined
in Thread (DefineIn) and the top-level names are the aliases.

ClassInitGenerator: a class nested in an unnamed extension of a CLR type was
qualified with the CLR name (System::Threading::Thread::Mutex). It now takes the
Ruby name another library of the assembly gives that type - the builtins'
[RubyClass("Thread", Extends = typeof(Thread))]. Regenerating also renames the
private loader methods of one Kernel extension (LoadIronRuby__Builtins__Kernel_*
to LoadKernel_*); nothing else in Initializers.Generated.cs changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Largo Largo self-assigned this Oct 29, 2026
@Largo
Largo force-pushed the fix/thread-class-names branch from bb4a353 to 90f4d02 Compare October 29, 2026 14:35
@Largo
Largo merged commit d3a7cf9 into Largo:master Oct 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants