Skip to content

Conversation

ilyapuchka
Copy link
Collaborator

Would be cool if Dip will not depend on Foundation. The only dependency now is NSRecursiveLock. So I grabbed implementation from here

Still needs to be tested. Will try it later on virtual machine, but need to set it up first.

@AliSoftware
Copy link
Owner

Love the idea 👍

@ilyapuchka
Copy link
Collaborator Author

Managed to implement thread safety tests for Linux 😫 I think it will be not very hard to port all other tests. Will do that later in a separate PR.

["Test Case \'ThreadSafetyTests.testSingletonThreadSafety\' started."]
["Test Case \'ThreadSafetyTests.testSingletonThreadSafety\' passed (1.004 seconds)."]
["Test Case \'ThreadSafetyTests.testFactoryThreadSafety\' started."]
["Test Case \'ThreadSafetyTests.testFactoryThreadSafety\' passed (1.007 seconds)."]
["Test Case \'ThreadSafetyTests.testCircularReferenceThreadSafety\' started."]
["Test Case \'ThreadSafetyTests.testCircularReferenceThreadSafety\' passed (2.008 seconds)."]
["Executed 3 tests, with 0 failures (0 unexpected) in 4.019 (4.027) seconds"]
["Total executed 3 tests, with 0 failures (0 unexpected) in 4.019 (4.029) seconds"]

@ilyapuchka ilyapuchka mentioned this pull request Feb 8, 2016
}
}

sleep(2)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to let al the threads finish. Of course joining each thread would be better (then dispatch_xxx should return thread's pid). Again it's only because of limitations of swift-core libs, in this case xctest does not provide async utils yet.

@AliSoftware
Copy link
Owner

I'll trust you on this one and let you merge this when you're ready, because I won't have time to install a Linux VM on my Mac to test the code in there 😉

@ilyapuchka
Copy link
Collaborator Author

Ok =) I really hope it will work. At least with tests I was able to fix the issue with lock vs tryLock (first one was causing deadlock when switching threads in resolveDependencies block in the last test).

I'm still struggling to understand how to organize Linux tests better, for instance how to avoid putting all of them in one file, but I will address that in a separate PR.

ilyapuchka added a commit that referenced this pull request Feb 9, 2016
Implemented recursive lock using pthread mutex
@ilyapuchka ilyapuchka merged commit edb0d3e into develop Feb 9, 2016
@ilyapuchka ilyapuchka deleted the feature/pthread branch February 11, 2016 23:21
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