Sha256: 7a5c78e98434768855da29ffb19b5d3ce2c09787a28bc0833d4c9ec0ef534beb

Contents?: true

Size: 1.25 KB

Versions: 50

Compression:

Stored size: 1.25 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.

#ifndef GOSU_ASYNC_HPP
#define GOSU_ASYNC_HPP

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

namespace Gosu
{
    template<typename Result>
    class AsyncResult
    {
        boost::shared_ptr<boost::try_mutex> mutex;
        boost::shared_ptr<std::auto_ptr<Result> > result;
        
    public:
        AsyncResult(const boost::shared_ptr<boost::try_mutex>& mutex,
                    const boost::shared_ptr<std::auto_ptr<Result> >& result)
        : mutex(mutex), result(result)
        {
        }
        
        bool hasValue() const
        {
            boost::try_mutex::scoped_try_lock lock(*mutex);
            return lock && result->get();
        }
        
        std::auto_ptr<Result> takeValue()
        {
            boost::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

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
gosu-0.7.33 Gosu/Async.hpp
gosu-0.7.33-i386-mingw32 Gosu/Async.hpp
gosu-0.7.33-universal-darwin Gosu/Async.hpp
gosu-0.7.32 Gosu/Async.hpp
gosu-0.7.32-i386-mingw32 Gosu/Async.hpp
gosu-0.7.32-universal-darwin Gosu/Async.hpp
gosu-0.7.31 Gosu/Async.hpp
gosu-0.7.31-i386-mingw32 Gosu/Async.hpp
gosu-0.7.31-universal-darwin Gosu/Async.hpp
gosu-0.7.30 Gosu/Async.hpp
gosu-0.7.30-i386-mingw32 Gosu/Async.hpp
gosu-0.7.30-universal-darwin Gosu/Async.hpp
gosu-0.7.29-i386-mingw32 Gosu/Async.hpp
gosu-0.7.29 Gosu/Async.hpp
gosu-0.7.29-universal-darwin Gosu/Async.hpp
gosu-0.7.28-universal-darwin Gosu/Async.hpp
gosu-0.7.28 Gosu/Async.hpp
gosu-0.7.28-i386-mingw32 Gosu/Async.hpp
gosu-0.7.27.1 Gosu/Async.hpp
gosu-0.7.27.1-i386-mingw32 Gosu/Async.hpp