Git Product home page Git Product logo

tasks's People

Contributors

mhogomchungu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tasks's Issues

Feature request: Task progress

Hey @mhogomchungu Asante sana for writing this particular library since task management is something that has been missing for Qt and all the other attempts made online were not doing it like the way we have always desired. Your solution seems to address the Async Wait via Task::await().

Now I may want to show my users progress in terms of a progress bar or percentage. Would you mind considering adding that for me please.

Idea: Queuing

It would be nice to put a series of async calls to compose a indexed queue which, on complete, shoud execute a trigger. something like this:

Task::queue([] {
    Task::run( fn1 ).then( use1 );
    Task::run( fn2 ).then( use2 );
    Task::run( fn3 ).then( use3 );
}).then( doSomething );

I believe this is better than a sequence of await() calls, because it would take advantage of using many threads as possible.

Performance and design issues

Hi,

This issue is, in essence, a reply to your comment on http://cukic.co/2016/01/17/asynqt-framework-making-qfuture-useful/

@Mnogo mchungu

I've seen the library (on reddit). It is interesting, especially the future class design,
but I have a few issues with it. I'll reply on github. :)

For this library, I needed to use QFutures (would not be my first choice) and not roll out my own,
because I already have a QFuture-based library in which I want to use this code.

While the title of the issue sounds overly serious, there are a few potential problems
I see with the current version of your library.

  • spinning new threads is not cheap (and new event loops). So, the await will actually be quite expensive. Now, until we get the proper await in C++17, this is one of the valid solutions for this problem. I'd advise you to also check boost.coroutine, maybe you'll get ideas how to improve this without relying on Qt's event loop. (another thing - I haven't checked the QEventLoop implementation - what happens to the events that are already scheduled for processing in the current event loop when one of the events invokes await?)
  • wrapping stuff in std::function is also not cheap. From what I've seen in the API, you would be able to avoid using std::function for the most part, and receive functions as template arguments (something like tasks::future_impl<T, StartFunction, CancelFunction, GetFunction>), and only if the user actually wants to save the future in a variable that can not be declared as auto, perform the type-erasure and create tasks::future. Though, on the other hand, this would make the code much more difficult to maintain.

The idea is really nice, and would be awesome to have a library like this for C++/Qt. (maybe some things should be in Qt like .then, but I don't expect we will see many improvements to QFuture unfortunately)

Cheers,
Ivan

p.s. I hope I didn't sound offputting - I sometimes do unwantingly sound negative, but I'm really not :)

How to install?

I don't have much practice in installing libraries in qt. How is yours installed? It would be of great help to me for a project.

Thanks for reading me.

infinite recursion

Hi,

When I creating a future that combines multiple functions like this:

auto bb = [](){	
qDebug() << "run bb";
return 6 ; } ;

Task::run( bb,bb );

I found that the function call has an infinite recursion.

	template< typename ... T >
	Task::future< void >& run( std::function< void() >f,T ... t )
	{
		auto& e = _private_future< void >() ;

		_private_add_task( e,std::move( f ),std::move( t ) ... ) ;

		return e ;
	}
	template< typename ... T >
	void _private_add_task( Task::future< void >& f,std::function< void() >&& e,T&& ... t )
	{
		_private_add_void( f,Task::run( std::move( e ) ),std::function< void() >( [](){} ) ) ;

		_private_add_task( f,std::move( t ) ... ) ;
	}

Task::run( std::move( e ) ) will call

Task::future< void >& run( std::function< void() >f,T ... t )

and Task::future< void >& run( std::function< void() >f,T ... t ) will call

_private_add_task

So circulate

My development environment is win7+VS2015

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.