k2snowman69 / threadily Goto Github PK
View Code? Open in Web Editor NEWA C++ object marshalling system across threads
License: MIT License
A C++ object marshalling system across threads
License: MIT License
Try running this unit test
TEST_METHOD(ThreadObject_Observable_Vector_ThreadObject)
{
auto threadManager = std::make_shared<ThreadManager>();
threadManager->getOrCreateThread(ThreadIds::Service, std::set<unsigned int>({ ThreadIds::App }));
threadManager->getOrCreateThread(ThreadIds::App, std::set<unsigned int>({ ThreadIds::UI }));
threadManager->getOrCreateThread(ThreadIds::UI);
auto threadObjectManager = std::make_shared<ThreadObjectManager<ParentThreadObject>>(threadManager);
auto childThreadObjectManager = std::make_shared<ThreadObjectManager<ExampleThreadObject>>(threadManager);
auto threadObject_UI = threadObjectManager->getOrCreateObject(ThreadIds::UI, 0);
auto threadObject_Service = threadObjectManager->getOrCreateObject(ThreadIds::Service, 0);
// set up a waiter until we get a notification on the UI thread that something has been completed
ReadyEvent e;
auto subscribeHandle = threadObject_UI->exampleObjects->subscribe([&e](std::shared_ptr<ExampleThreadObject> newValue, size_t index, ObservableActionType action)
{
e.finished();
});
auto sizeBefore = threadObject_UI->exampleObjects->size();
auto newChildObject = childThreadObjectManager->getOrCreateObject(ThreadIds::Service, 4);
newChildObject->name->set(L"new name");
threadObject_Service->exampleObjects->insert(0, newChildObject);
e.wait();
Assert::IsTrue(nullptr != threadObject_UI->exampleObjects->at(0), L"Make sure the UI object was set");
Assert::IsTrue(threadObject_UI->exampleObjects->size() == sizeBefore + 1, L"Expect example objects list to be size of 1");
Assert::IsTrue(ThreadIds::UI == threadObject_UI->exampleObjects->at(0)->getThreadId(), L"Expected the example object to be running on the UI thread");
Assert::IsTrue(ThreadIds::Service == threadObject_Service->exampleObjects->at(0)->getThreadId(), L"Expected the example object to be running on the Service thread");
Assert::AreEqual(threadObject_UI->exampleObjects->at(0)->getId(), threadObject_Service->exampleObjects->at(0)->getId(), L"Make sure they have the same value");
Assert::IsTrue(threadObject_UI->exampleObjects->at(0).get() != threadObject_Service->exampleObjects->at(0).get(), L"Make sure they are two distinct pointers");
Assert::AreEqual(threadObject_UI->exampleObjects->at(0)->name->get(), threadObject_Service->exampleObjects->at(0)->name->get(), L"Make sure they have the same name value");
}
Currently Id is required to be a unsigned integer. Some objects may have multiple reference id's of which make up the id and that needs to be represented in the system.
Moving to makefiles should have the following advantages:
Also it gets us away from VS unit testing and we can then use something like https://github.com/banditcpp/bandit which should also be cross platform.
There seems to be some strong pointer reference issues regarding contents of a Observable<vector>. I think writing some tests that verify the expected strong pointer reference count wouldn't be a bad idea to add to the system.
Windows requires all UI updates to happen on the main thread. We need a way to be able to provide this thread to threadily when it's creating the UI thread. I think the code was written but we don't have tests verifying that it works, if it works.
It seems that the lock in getObjectManager can return null causing null reference exceptions
Destructor for ThreadObject is causing intermittent crashes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.