-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds core.sync.event.EventAwaiter #64
base: master
Are you sure you want to change the base?
Conversation
This flag now is redundant for Windows platform
Is there a reason why there should be a completely new file event2.d for this? Why not append the additional type to event.d. You are allowed to have two types inside one file. Also the name Event2 is kind of ambiguous. People will ask, why are there two versions of Event? A better name is EventS or EventStruct so that it is more obvious what it is about. |
Yeah, and they're both structs too... |
Just too used that everything are classes outwards. Then another name like EventNoInitCheck or something. |
No
Yes, I can change this without any problems
Agree @adamdruppe Which name do you like best?
Do you mean that they should be a classes? To avoid copying, makes sense |
|
Another question is if we really need the old one. Why wouldn't it be initialized? That would be if the OS primitives fails to be created but one can argue if that is a fatal error. For the other primitives like mutex and semaphores, there are no such checks and if they fail there is usually an assert or Error is being thrown. If there is a chicken and egg problem during druntime initialization, then i think such special cases should be handled outside the Event type. At most there could be a |
I think the original one is how it is because D doesn't have any kind of default constructor, so you might forget to initialize it. Maybe just |
For backward compatibility with D: old |
I'd say we just brute force this one. Just replace the old one with the new one. Remove setIfInitialized() and replace it with just set(). setIfInitialized() can just call set() if we run into problems. |
|
Yes, I renamed it: dlang/dmd#15800 |
I actually meant remove Event and replace it with EventAwaiter (named just Event). Then the code inside the opend repo that uses setIfInitialized needs to be changed to set. |
This can lead to hard to find errors in a code that relies on possibility of not initializing an
Here is no such code except already changed in this PR upd: Besides this, I think the original name is incorrect: this structure itself is not an "event". This PR is a good reason to fix name too. |
Checking whether the
Event
object is in initialized state every time then any of its methods are called is waste of CPU resourcesI propose to intruduce new event struct which provides RAII interface and methods doesn't poisoned by
if (m_initalized)
checks