Skip to content

Console class allocation #11

Description

@s-daveb

As mentioned in commit f059129 (Make memory/cpu static members of console), we should figure out the proper way to share components of the emulator between the different components that interact.

Coming from a C++/C# background, we are familiar with singletons/static classes (respectively), but from what i was reading here, in D, local and static variables exist on a per-thread basis. This means if we simply create a static class, each thread will have a copy of the Console object, and a separate CPU/Memory object, since those are allocated in the console.

We have two options, and I want to hear your opinions, @bobomb:

  1. Use the singleton pattern, alá C++ (private ctor, private shared instanceRef, public static getReference() method, manual thread locking for each object)
  2. Use a shared static class. This will be initialized before main() is even called. All Console members will need to be marked shared static, but this might handle any threading issues that might arise.

(I still believe we should implement the different processors of the NES in different threads; even though we could just time-slice, I feel this will be more akin to how the real NES operated, and we can let each thread implement its own timing)

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions