Commit Graph

12 Commits

Author SHA1 Message Date
Mike Morris
99ba07deb3 accept options object argument to new mbgl.Map()
instead of requiring inheritence, drops mbgl.FileSource

pass NodeFileSource* around as v8::External
2015-08-04 15:06:25 -04:00
Thiago Marcos P. Santos
b602835626 Fix invalid NodeRequest reference
On the code path built with node v0.12.4, we are storing
an invalid reference to NodeRequest on the "pending" list. It will
crash when we need to access it like we do when canceling a request.

Ideally we should just have a "std::unordered_map<mbgl::Resource,
v8::UniquePersistent>" but that is not possible because the move
semantics are not fully implemented until V8 v4.3.22. It can be used
on a std::vector but not on a std::map.

See: https://code.google.com/p/v8/issues/detail?id=3669

The solution for keep using C++11 move semantics is to declare the
v8::CopyablePersistentTraits shenanigans and explicitly clear the
v8::Persistent (like we do already for node v0.10).

When Node gets V8 v4.3.22+ we can go back to v8::UniquePersistent
with a more clear implementation.
2015-06-15 13:54:20 +03:00
Thiago Marcos P. Santos
34ef7ac003 Implement request coalescing and synchronous request cancellation
When requests are made to the FileSource, we now group them by
resource, similarly to what is done on the native implementation. The
file source will reuse the same Response for all the requests on the
observer list.

The NodeRequest no longer holds a reference to the mbgl::Request, so
we can cancel it synchronously. This is needed to avoid a deadlock
when releasing the NodeMap resources with pending requests.

Before:

- Main thread | NodeMap::release()
- Main thread | mbgl::~Map()
- Main thread | Blocks waiting for the Map thread to join
- Map thread  | mbgl::Request::cancel()
- Map thread  | NodeFileSource posts the "cancel" message to main thread
- *deadlock*  | Map thread cannot join because mbgl::Request holds a
                reference to the Map thread main loop. Main thread is
                blocked, never gets the "cancel" message.

Now:

- Main thread | NodeMap::release()
- Main thread | mbgl::~Map()
- Main thread | Blocks waiting for the Map thread to join
- Map thread  | Request::cancel()
- Map thread  | NodeFileSource::cancel(), destroys the mbgl::Request
                synchronously, mutex guarded access. We also send
                a notification to cancel the NodeRequest on the main
                thread.
- Map thread  | Map thread joins.
- Main thread | NodeMap::release() returns
- Main thread | NodeRequest gets canceled. If NodeRequest replies
                before it gets the "cancel" message, nothing happens,
                notification gets discarded.
2015-06-15 01:52:15 +03:00
Thiago Marcos P. Santos
b4f21b73d0 Removed unused method on NodeFileSource 2015-06-08 15:40:45 +03:00
Mike Morris
cb47f902e1 #include <memory> in node_file_source.hpp 2015-05-27 18:40:53 -04:00
Mike Morris
11b214fed6 if/else on NODE_MODULE_VERSION instead of UV_VERSION 2015-05-14 12:55:54 -04:00
Mike Morris
c0fe624ecd add node v0.12 and io.js compatibility 2015-05-14 12:55:54 -04:00
Mike Morris
1b9f98440a ignore GCC diagnostics for node.h 2015-05-13 12:58:34 -04:00
Mike Morris
1eeb7b65e9 update travis script for https://github.com/mapbox/mapbox-gl-native/pull/1339
refactor mbgl travis scripts

source travis_helper.sh, run setup.sh

pushd/popd

sudo false

travis matrix with c++14 support?

drop setup_mesa.sh

update binding.gyp

language: c

drop thread_object, add async_queue

fix async_queue.hpp includes

std::make_unique

pip install awscli
2015-05-13 12:58:04 -04:00
Mike Morris
ca897ce407 bump mbgl
drop mbgl::Environment from NodeFileSource
switch to mbgl::Map::Mode::Still
2015-04-29 15:26:29 -04:00
Mike Morris
9a297051c7 adapt NodeFileSource around mbgl::Environment additions 2015-03-19 17:45:15 -04:00
Konstantin Käfer
07867edd47 initial version with updated build system 2015-02-04 18:21:39 +01:00