Comments (1)
I have an observation that is this topic related. I've been testing actions in Urho in order to implement logic for my actual project. What I need is an ability to write asynchronous code in order to simulate a lot of objects, let's say thousands.
Unfortunatelly the performance of actions for such purposes is not good enough. My test was set up with a simple scene with a lot of nodes, each of them having attached a component which started some tasks, continuously repeating them. The performance hit was tremendous when delays between tasks were small, e.g. tens or hundreds of miliseconds. I checked two approaches, with DelayTime which is an Urho action, and even with native Task.Delay.
I was trying to improve the overall solution by implementing synchronization context which executed tasks during update event, but it didn't help at all. The next approach was with a custom task scheduler which was processing tasks in a thread. Although there were no framerate drops anymore, tasks couldn't be processed "on time", making small delays lasting more than they should do.
The problem is that it is a very time consuming to call all of these queued callbacks if delays are small. There is still a possibility that I am doing something wrong or do not completely know how to handle it correctly. But, anyway, I figured out how it could be solved without tasks, but still with an asynchronous support for logic of my project.
I simply created a component which processes Func<float, bool>
delegates. The delegate takes delta time as an input parameter and returns bool whether it should be treated as finished or not. Queued delegates are processed in an update event. If they are finished, they are removed from collection.
It is quite easy to implement behaviors like a Sequence
, WhenAll
or WhenAny
. Sequence has an internal list of mentioned delegates and advances actually processed delegate, returning true only if all of them were finished one by one. WhenAll runs all of stored delegates on every update event, and returns true if all of them returned true (the ones finished earlier are removed from internal collection). Higher-level behaviors can be implemented with an IEnumerable<Func<float, bool>>
because it is easier to implement complex logic with generators.
The fact is that with this approach I could simulate thousands of objects with no CPU freezes due to synchronization. The only drawback is a constant FPS drop, but it was not something big. The next con is that it is not as handy in use as tasks.
from urho.
Related Issues (20)
- Dependency injection for Application HOT 2
- Red/Blue color reversal with .png files on iOS
- Textures get deleted unintendedly
- Showing UrhoSurface shows status bar on iOS
- Question about left hand coordinates HOT 2
- Visual Studio 2019 Community and Xamarin + Urho -- Could not find resource
- urho Binding xamarin forms WPF
- Urho3D view is wrong size with iOS 14 HOT 2
- Provide Nuget Packages for .NET Core 3.1 of UrhoSharp.WinForms HOT 6
- UrhoSharp on UWP Xamarin Forms - Disposes when you Navigate to new Page
- Linux support
- Cannot Build UrhoSharp - Build Instructions seem broken
- License is ambiguous
- How to setup the UrhoSharp engine to render on a live wallpaper on Xamarin Android platform ?
- How to update with the latest 3D Engine version?
- Urho.Forms.UrhoSurface.OnDestroy(); Crash
- Inverse Kinematic functionality missing
- Placing an item on the wall with UrhoSharp
- MAUI Support
- UnhandledException Not Firing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urho.