MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / AddWatcher

Method AddWatcher

cpp/src/Manager.cpp:3931–3952  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Add a watcher to the list -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3929// Add a watcher to the list
3930//-----------------------------------------------------------------------------
3931bool Manager::AddWatcher
3932(
3933 pfnOnNotification_t _watcher,
3934 void* _context
3935)
3936{
3937 // Ensure this watcher is not already on the list
3938 m_notificationMutex->Lock();
3939 for( list<Watcher*>::iterator it = m_watchers.begin(); it != m_watchers.end(); ++it )
3940 {
3941 if( ((*it)->m_callback == _watcher ) && ( (*it)->m_context == _context ) )
3942 {
3943 // Already in the list
3944 m_notificationMutex->Unlock();
3945 return false;
3946 }
3947 }
3948
3949 m_watchers.push_back( new Watcher( _watcher, _context ) );
3950 m_notificationMutex->Unlock();
3951 return true;
3952}
3953
3954//-----------------------------------------------------------------------------
3955// <Manager::RemoveWatcher>

Callers 2

mainFunction · 0.45
mainFunction · 0.45

Calls 4

LockMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected