Skip to content

Commit

Permalink
env: add watched_providers for AsyncListener
Browse files Browse the repository at this point in the history
Now the second field in asyncFlags will tell if the provider is
currently being watched, or listened for.

Signed-off-by: Timothy J Fontaine <[email protected]>
  • Loading branch information
trevnorris committed Feb 5, 2014
1 parent 4a9af3f commit d9e1e4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() &&
Expand Down
3 changes: 3 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,15 @@ 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.
inline AsyncListener();

enum Fields {
kHasListener,
kWatchedProviders,
kFieldsCount
};

Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d9e1e4c

Please sign in to comment.