reader_writer_lock.h
Go to the documentation of this file.
/*
Copyright (c) 2005-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "internal/_deprecated_header_message_guard.h"
#if !defined(__TBB_show_deprecation_message_reader_writer_lock_H) && defined(__TBB_show_deprecated_header_message)
#define __TBB_show_deprecation_message_reader_writer_lock_H
#pragma message("TBB Warning: tbb/reader_writer_lock.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.")
#endif
#if defined(__TBB_show_deprecated_header_message)
#undef __TBB_show_deprecated_header_message
#endif
#ifndef __TBB_reader_writer_lock_H
#define __TBB_reader_writer_lock_H
#define __TBB_reader_writer_lock_H_include_area
#include "internal/_warning_suppress_enable_notice.h"
#include "tbb_thread.h"
#include "tbb_allocator.h"
#include "atomic.h"
namespace tbb {
namespace interface5 {
class __TBB_DEPRECATED_VERBOSE_MSG("tbb::reader_writer_lock is deprecated, use std::shared_mutex")
reader_writer_lock : tbb::internal::no_copy {
public:
friend class scoped_lock;
friend class scoped_lock_read;
enum status_t { waiting_nonblocking, waiting, active, invalid };
reader_writer_lock() {
internal_construct();
}
~reader_writer_lock() {
internal_destroy();
}
class scoped_lock : tbb::internal::no_copy {
public:
friend class reader_writer_lock;
scoped_lock(reader_writer_lock& lock) {
internal_construct(lock);
}
~scoped_lock() {
internal_destroy();
}
void* operator new(size_t s) {
return tbb::internal::allocate_via_handler_v3(s);
}
void operator delete(void* p) {
tbb::internal::deallocate_via_handler_v3(p);
}
private:
reader_writer_lock *mutex;
scoped_lock* next;
atomic<status_t> status;
scoped_lock();
void __TBB_EXPORTED_METHOD internal_construct(reader_writer_lock&);
void __TBB_EXPORTED_METHOD internal_destroy();
};
class scoped_lock_read : tbb::internal::no_copy {
public:
friend class reader_writer_lock;
scoped_lock_read(reader_writer_lock& lock) {
internal_construct(lock);
}
~scoped_lock_read() {
internal_destroy();
}
void* operator new(size_t s) {
return tbb::internal::allocate_via_handler_v3(s);
}
void operator delete(void* p) {
tbb::internal::deallocate_via_handler_v3(p);
}
private:
reader_writer_lock *mutex;
scoped_lock_read *next;
atomic<status_t> status;
scoped_lock_read();
void __TBB_EXPORTED_METHOD internal_construct(reader_writer_lock&);
void __TBB_EXPORTED_METHOD internal_destroy();
};
void __TBB_EXPORTED_METHOD lock();
bool __TBB_EXPORTED_METHOD try_lock();
void __TBB_EXPORTED_METHOD lock_read();
bool __TBB_EXPORTED_METHOD try_lock_read();
void __TBB_EXPORTED_METHOD unlock();
private:
void __TBB_EXPORTED_METHOD internal_construct();
void __TBB_EXPORTED_METHOD internal_destroy();
bool start_write(scoped_lock *);
void set_next_writer(scoped_lock *w);
void end_write(scoped_lock *);
bool is_current_writer();
void start_read(scoped_lock_read *);
void unblock_readers();
void end_read();
atomic<scoped_lock_read*> reader_head;
atomic<scoped_lock*> writer_head;
atomic<scoped_lock*> writer_tail;
tbb_thread::id my_current_writer;
atomic<uintptr_t> rdr_count_and_flags; // used with __TBB_AtomicOR, which assumes uintptr_t
};
} // namespace interface5
using interface5::reader_writer_lock;
} // namespace tbb
#include "internal/_warning_suppress_disable_notice.h"
#undef __TBB_reader_writer_lock_H_include_area
#endif /* __TBB_reader_writer_lock_H */
tbb::__TBB_DEPRECATED_VERBOSE_MSG
class __TBB_DEPRECATED_VERBOSE_MSG("tbb::aligned_space is deprecated, use std::aligned_storage") aligned_space
Block of space aligned sufficiently to construct an array T with N elements.
Definition: aligned_space.h:43
tbb::internal::deallocate_via_handler_v3
void __TBB_EXPORTED_FUNC deallocate_via_handler_v3(void *p)
Deallocates memory using FreeHandler.
Definition: cache_aligned_allocator.cpp:232
tbb_thread.h
_deprecated_header_message_guard.h
id
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id id
Definition: ittnotify_static.h:172
tbb::internal::no_copy
Base class for types that should not be copied or assigned.
Definition: tbb_stddef.h:330
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
lock
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
Definition: ittnotify_static.h:121
atomic.h
_warning_suppress_disable_notice.h
tbb::internal::allocate_via_handler_v3
void *__TBB_EXPORTED_FUNC allocate_via_handler_v3(size_t n)
Allocates memory using MallocHandler.
Definition: cache_aligned_allocator.cpp:224
s
void const char const char int ITT_FORMAT __itt_group_sync s
Definition: ittnotify_static.h:91
_warning_suppress_enable_notice.h
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
__TBB_EXPORTED_METHOD
#define __TBB_EXPORTED_METHOD
Definition: tbb_stddef.h:98
tbb_allocator.h

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.