Working on an Executor to replace Job* functionality
#1
I'm working on Executor functionality equivalent to what's in Java but that anticipates where C++ might be going with it. There's currently a proposal to add something similar to the C++ language.

If people aren't familiar with how Executors work in Java take a look at a few examples.

http://tutorials.jenkov.com/java-util-co...rvice.html
http://www.baeldung.com/java-executor-service-tutorial

Currently I'm just playing with some ideas. C++11 has added so much to the language I'm not yet familiar with I'm trying to work through some of the issues. For example, trying to use std::future like std::thread does isn't easy.

This is really rough, doesn't compile, and is basically my current playground for trying to figure it out:

https://github.com/jimfcarroll/xbmc/blob...ecutor.cpp
https://github.com/jimfcarroll/xbmc/blob...rService.h

If anyone has an comments, suggestions, or objections, please let me know.

Jim
Reply
#2
Are you aware of this: https://github.com/xbmc/xbmc/blob/54b1a2...ger.h#L127 ? It already replaces the simple case. You could add similar helper methods and wrapper classes that returns futures.
Reply
#3
(2018-02-05, 21:11)takoi Wrote: Are you aware of this: https://github.com/xbmc/xbmc/blob/54b1a2...ger.h#L127 ? It already replaces the simple case. You could add similar helper methods and wrapper classes that returns futures.
 Yes. I wanted to simplify the entire set of classes all together. There's currently CJob, CJobQueue, CJobManager, CJobWorker, CLambdaJob (more?). I wanted to replace all of the functionality with an easier to manage pattern for selecting how jobs get executed, one that's fairly well understood in other languages and will eventually be added to C++. Then implement it with a fixed thread pool.

This was basically prompted by the fact that it takes me a while to figure out problems every time I dive into the Job functionality. I assumed I'm not the only one. Maybe that's not true.

The std::future functionality might not even be necessary but it's what any new standard will support so I didn't want to neglect it.

I just updated the code. Currently the only implementation doesn't do any threading work. I was just trying to get the interface right.
Reply
#4
If you can replace all that, that's great! but there's a lot of old awfulness using those things. That's why it might be better to start with adding alternative api, move things over and then replace it. E.g two things we don't have any replacement for yes is cancellation and progress. I doubt this will part of any executor api so uncoupling that from the job manager system might be a place to start.
Reply
#5
Just updated with a working executor class. It's rudimentary and isn't used in the main codebase yet but if anyone is interested in the API, take a look.

https://github.com/jimfcarroll/xbmc/blob...rService.h
https://github.com/jimfcarroll/xbmc/blob...entDeque.h

These are the tests:

https://github.com/jimfcarroll/xbmc/blob...ecutor.cpp
https://github.com/jimfcarroll/xbmc/blob...anisms.cpp
Reply

Logout Mark Read Team Forum Stats Members Help
Working on an Executor to replace Job* functionality0
This forum uses Lukasz Tkacz MyBB addons.