env: add watched_providers for AsyncListener

Now the second field in asyncFlags will tell if the provider is
currently being watched, or listened for.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
This commit is contained in:
Trevor Norris 2014-01-21 11:32:55 -08:00
parent 4a9af3fecb
commit d9e1e4c661
3 changed files with 13 additions and 0 deletions

View File

@ -126,6 +126,10 @@ inline bool Environment::AsyncListener::has_listener() const {
return fields_[kHasListener] > 0;
}
inline uint32_t Environment::AsyncListener::watched_providers() const {
return fields_[kWatchedProviders];
}
inline Environment::DomainFlag::DomainFlag() {
for (int i = 0; i < kFieldsCount; ++i) fields_[i] = 0;
}
@ -253,6 +257,11 @@ inline bool Environment::has_async_listener() const {
return const_cast<Environment*>(this)->async_listener()->has_listener();
}
inline uint32_t Environment::watched_providers() const {
// The const_cast is okay, it doesn't violate conceptual const-ness.
return const_cast<Environment*>(this)->async_listener()->watched_providers();
}
inline bool Environment::in_domain() const {
// The const_cast is okay, it doesn't violate conceptual const-ness.
return using_domains() &&

View File

@ -191,6 +191,7 @@ class Environment {
inline uint32_t* fields();
inline int fields_count() const;
inline bool has_listener() const;
inline uint32_t watched_providers() const;
private:
friend class Environment; // So we can call the constructor.
@ -198,6 +199,7 @@ class Environment {
enum Fields {
kHasListener,
kWatchedProviders,
kFieldsCount
};
@ -272,6 +274,7 @@ class Environment {
inline uv_loop_t* event_loop() const;
inline bool has_async_listener() const;
inline bool in_domain() const;
inline uint32_t watched_providers() const;
static inline Environment* from_immediate_check_handle(uv_check_t* handle);
inline uv_check_t* immediate_check_handle();

View File

@ -283,6 +283,7 @@
// Needs to be the same as src/env.h
var kHasListener = 0;
var kWatchedProviders = 1;
// Flags to determine what async listeners are available.
var HAS_CREATE_AL = 1 << 0;