Click here to Skip to main content
12,359,604 members (67,840 online)
Click here to Skip to main content

Stats

38.9K views
514 downloads
25 bookmarked
Posted

Testing reader/writer locks

, 20 Jan 2009 CPOL
This article describes testing the results of reader/writer locks on Windows XP/Vista Uniprocessor and Multi-core PCs.
#pragma once 

template <typename lock_t>
class ref_shared_lock_t
{
public:
	ref_shared_lock_t(lock_t& lock) : m_lock(lock)
	{
		m_lock.acquireLockShared();
	}
	~ref_shared_lock_t()
	{
		m_lock.releaseLockShared();
	}
private:
	lock_t& m_lock;
	ref_shared_lock_t& operator=(const ref_shared_lock_t&); //C4512 warning
};

template <typename lock_t>
class ref_exclusive_lock_t
{
public:
	ref_exclusive_lock_t(lock_t& lock) : m_lock(lock)
	{
		m_lock.acquireLockExclusive();
	}
	~ref_exclusive_lock_t()
	{
		m_lock.releaseLockExclusive();
	}
private:
	lock_t& m_lock;
	ref_exclusive_lock_t& operator=(const ref_exclusive_lock_t&); //C4512 warning
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Valery Grebnev
Software Developer
Canada Canada
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 21 Jan 2009
Article Copyright 2009 by Valery Grebnev
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid