2016-05-04 02:29:58 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-02-15 17:49:07 +00:00
|
|
|
#include <cxxreact/Executor.h>
|
2016-05-04 02:29:58 +00:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class exists so that we have a type for the shared_ptr on ExecutorToken
|
|
|
|
* that implements a virtual destructor.
|
|
|
|
*/
|
|
|
|
class PlatformExecutorToken {
|
|
|
|
public:
|
|
|
|
virtual ~PlatformExecutorToken() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class corresponding to a JS VM that can call into native modules. This is
|
|
|
|
* passed to native modules to allow their JS module calls/callbacks to be
|
|
|
|
* routed back to the proper JS VM on the proper thread.
|
|
|
|
*/
|
|
|
|
class ExecutorToken {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* This should only be used by the implementation of the platform ExecutorToken.
|
|
|
|
* Do not use as a client of ExecutorToken.
|
|
|
|
*/
|
|
|
|
explicit ExecutorToken(std::shared_ptr<PlatformExecutorToken> platformToken) :
|
|
|
|
platformToken_(platformToken) {}
|
|
|
|
|
|
|
|
std::shared_ptr<PlatformExecutorToken> getPlatformExecutorToken() const {
|
|
|
|
return platformToken_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const ExecutorToken& other) const {
|
|
|
|
return platformToken_.get() == other.platformToken_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::shared_ptr<PlatformExecutorToken> platformToken_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
template<>
|
|
|
|
struct hash<facebook::react::ExecutorToken> {
|
2017-03-23 18:25:28 +00:00
|
|
|
size_t operator()(const facebook::react::ExecutorToken& token) const {
|
2016-05-04 02:29:58 +00:00
|
|
|
return (size_t) token.getPlatformExecutorToken().get();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|