Sha256: 7d2c40ddef815b6e22d67257da0aed296c4a60d779aeb39556712bd0a814cd14

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

#include <Gosu/Async.hpp>
#include <Gosu/Graphics.hpp>
#include <Gosu/Image.hpp>
#include <Gosu/TR1.hpp>
#include <Gosu/Window.hpp>

using namespace std;
using namespace std::tr1;

namespace Gosu
{
    namespace
    {
        void asyncNewImage_Impl(Window& window, std::wstring filename,
                            Window::SharedContext context,
                            shared_ptr<try_mutex> mutex,
                            shared_ptr<std::auto_ptr<Image> > result)
        {
            try_mutex::scoped_lock lock(*mutex);
            (*context)();
            result->reset(new Image(window.graphics(), filename));
        }
    }
}

Gosu::AsyncResult<Gosu::Image>
    Gosu::asyncNewImage(Window& window, const std::wstring& filename)
{
	shared_ptr<try_mutex> mutex(new try_mutex);
	shared_ptr<auto_ptr<Image> > image(new std::auto_ptr<Image>);
	thread thread(bind(asyncNewImage_Impl,
						ref(window),
                        filename,
						window.createSharedContext(),
						mutex,
                        image));
	return AsyncResult<Image>(mutex, image);
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gosu-0.7.48 GosuImpl/Async.cpp
gosu-0.7.47.1 GosuImpl/Async.cpp
gosu-0.7.46 GosuImpl/Async.cpp
gosu-0.7.45 GosuImpl/Async.cpp
gosu-0.7.44 GosuImpl/Async.cpp
gosu-0.7.43 GosuImpl/Async.cpp
gosu-0.7.41 GosuImpl/Async.cpp
gosu-0.7.40 GosuImpl/Async.cpp
gosu-0.7.39 GosuImpl/Async.cpp
gosu-0.7.38 GosuImpl/Async.cpp
gosu-0.7.37 GosuImpl/Async.cpp
gosu-0.7.36.2 GosuImpl/Async.cpp
gosu-0.7.35 GosuImpl/Async.cpp