Sha256: 98997120f5f2adff09eccc39de0db11e489654bc917cbbbb35b633653adc59ea

Contents?: true

Size: 1.26 KB

Versions: 39

Compression:

Stored size: 1.26 KB

Contents

// Undocumented for the first few iterations. Interface may change rapidly.
// This is mainly a proof of concept. Stability will be the highest on OS X.

#if 0
#ifndef GOSU_ASYNC_HPP
#define GOSU_ASYNC_HPP

#include <Gosu/Fwd.hpp>
#include <Gosu/TR1.hpp>
#include <thread>
#include <memory>
#include <string>

namespace Gosu
{
    template<typename Result>
    class AsyncResult
    {
        std::tr1::shared_ptr<std::tr1::try_mutex> mutex;
        std::tr1::shared_ptr<std::auto_ptr<Result> > result;
        
    public:
        AsyncResult(const std::tr1::shared_ptr<std::tr1::try_mutex>& mutex,
                    const std::tr1::shared_ptr<std::auto_ptr<Result> >& result)
        : mutex(mutex), result(result)
        {
        }
        
        bool hasValue() const
        {
            std::tr1::try_mutex::scoped_try_lock lock(*mutex);
            return lock && result->get();
        }
        
        std::auto_ptr<Result> takeValue()
        {
            std::tr1::try_mutex::scoped_lock lock(*mutex);
            return *result;
        }
    };
    
	// TODO: Will only work if the window doesn't die inbetween.
	// TODO: More functions to come; or a general interface?

	AsyncResult<Image>
		asyncNewImage(Window& window, const std::wstring& filename);
}

#endif
#endif

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
gosu-0.7.48-x86-mingw32 Gosu/Async.hpp
gosu-0.7.48 Gosu/Async.hpp
gosu-0.7.47.1-x86-mingw32 Gosu/Async.hpp
gosu-0.7.47.1 Gosu/Async.hpp
gosu-0.7.46 Gosu/Async.hpp
gosu-0.7.46-x86-mingw32 Gosu/Async.hpp
gosu-0.7.45-x86-mingw32 Gosu/Async.hpp
gosu-0.7.45 Gosu/Async.hpp
gosu-0.7.45-universal-darwin Gosu/Async.hpp
gosu-0.7.44-x86-mingw32 Gosu/Async.hpp
gosu-0.7.44-universal-darwin Gosu/Async.hpp
gosu-0.7.44 Gosu/Async.hpp
gosu-0.7.43-universal-darwin Gosu/Async.hpp
gosu-0.7.43 Gosu/Async.hpp
gosu-0.7.43-x86-mingw32 Gosu/Async.hpp
gosu-0.7.41 Gosu/Async.hpp
gosu-0.7.41-x86-mingw32 Gosu/Async.hpp
gosu-0.7.41-universal-darwin Gosu/Async.hpp
gosu-0.7.40 Gosu/Async.hpp
gosu-0.7.40-x86-mingw32 Gosu/Async.hpp