Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
e306d5b2
Commit
e306d5b2
authored
Jun 01, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - WSubject now uses read/write tickets too
[DOC] [STYLE]
parent
989b9942
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
40 deletions
+62
-40
src/common/WSharedObject.h
src/common/WSharedObject.h
+14
-14
src/dataHandler/WSubject.cpp
src/dataHandler/WSubject.cpp
+22
-15
src/dataHandler/WSubject.h
src/dataHandler/WSubject.h
+18
-5
src/dataHandler/test/WSubject_test.h
src/dataHandler/test/WSubject_test.h
+2
-4
src/graphicsEngine/WShader.h
src/graphicsEngine/WShader.h
+1
-1
src/modules/isosurfaceRaytracer/WMIsosurfaceRaytracer.h
src/modules/isosurfaceRaytracer/WMIsosurfaceRaytracer.h
+5
-1
No files found.
src/common/WSharedObject.h
View file @
e306d5b2
...
...
@@ -141,20 +141,6 @@ public:
boost
::
shared_ptr
<
WCondition
>
m_objectChangeCondition
;
};
/**
* Use a shared_ptr since the shared and unique locks from boost are non-copyable.
*/
typedef
boost
::
shared_ptr
<
WSharedObjectAccess
>
WSharedAccess
;
/**
* This method distributes access objects. These objects are able to read/write lock the object and grant access to it, in
* a thread-safe manner.
*
* \deprecated do not use this anymore. Use \ref getReadTicket and \ref getWriteTicket instead
* \return the access object which allows thread safe access to the object.
*/
WSharedAccess
getAccessObject
();
/**
* Type for read tickets.
*/
...
...
@@ -181,6 +167,20 @@ public:
*/
WriteTicket
getWriteTicket
(
bool
suppressNotify
=
false
)
const
;
/**
* Use a shared_ptr since the shared and unique locks from boost are non-copyable.
*/
typedef
boost
::
shared_ptr
<
WSharedObjectAccess
>
WSharedAccess
;
/**
* This method distributes access objects. These objects are able to read/write lock the object and grant access to it, in
* a thread-safe manner.
*
* \deprecated do not use this anymore. Use getReadTicket and getWriteTicket instead
* \return the access object which allows thread safe access to the object.
*/
WSharedAccess
getAccessObject
();
/**
* This condition fires whenever the encapsulated object changed. This is fired automatically by endWrite().
*
...
...
src/dataHandler/WSubject.cpp
View file @
e306d5b2
...
...
@@ -37,7 +37,6 @@
WSubject
::
WSubject
()
:
m_datasets
(),
m_datasetAccess
(
m_datasets
.
getAccessObject
()
),
m_changeCondition
(
boost
::
shared_ptr
<
WConditionSet
>
(
new
WConditionSet
()
)
),
m_listChangeCondition
(
boost
::
shared_ptr
<
WConditionSet
>
(
new
WConditionSet
()
)
),
m_personalInfo
(
WPersonalInformation
::
createDummyInformation
()
)
...
...
@@ -46,7 +45,6 @@ WSubject::WSubject():
WSubject
::
WSubject
(
WPersonalInformation
personInfo
)
:
m_datasets
(),
m_datasetAccess
(
m_datasets
.
getAccessObject
()
),
m_changeCondition
(
boost
::
shared_ptr
<
WConditionSet
>
(
new
WConditionSet
()
)
),
m_listChangeCondition
(
boost
::
shared_ptr
<
WConditionSet
>
(
new
WConditionSet
()
)
),
m_personalInfo
(
personInfo
)
...
...
@@ -85,11 +83,11 @@ void WSubject::addDataSet( boost::shared_ptr< WDataSet > dataset )
void
WSubject
::
removeDataSet
(
boost
::
shared_ptr
<
WDataSet
>
dataset
)
{
m_d
ataset
Access
->
beginWrite
();
D
ataset
SharedContainerType
::
WriteTicket
l
=
m_datasets
.
getWriteTicket
();
// iterate and find, remove
Dataset
ContainerType
::
i
terator
fIt
=
std
::
find
(
m_datasetAccess
->
get
().
begin
(),
m_datasetAccess
->
get
().
end
(),
dataset
);
m_datasetAccess
->
get
().
erase
(
fIt
);
Dataset
I
terator
fIt
=
std
::
find
(
l
->
get
().
begin
(),
l
->
get
().
end
(),
dataset
);
l
->
get
().
erase
(
fIt
);
// also deregister condition
boost
::
shared_ptr
<
WCondition
>
c
=
dataset
->
getChangeCondition
();
...
...
@@ -97,7 +95,9 @@ void WSubject::removeDataSet( boost::shared_ptr< WDataSet > dataset )
{
m_changeCondition
->
remove
(
c
);
}
m_datasetAccess
->
endWrite
();
// unlock if some callback notified below wants to access the list
l
.
reset
();
m_changeCondition
->
notify
();
m_listChangeCondition
->
notify
();
...
...
@@ -105,33 +105,40 @@ void WSubject::removeDataSet( boost::shared_ptr< WDataSet > dataset )
void
WSubject
::
clear
()
{
m_d
ataset
Access
->
beginWrite
();
D
ataset
SharedContainerType
::
WriteTicket
l
=
m_datasets
.
getWriteTicket
();
// iterate and find, remove
for
(
Dataset
ContainerType
::
iterator
iter
=
m_datasetAccess
->
get
().
begin
();
iter
!=
m_datasetAccess
->
get
().
end
();
++
iter
)
for
(
Dataset
Iterator
iter
=
l
->
get
().
begin
();
iter
!=
l
->
get
().
end
();
++
iter
)
{
// also deregister condition
// also de
-
register condition
boost
::
shared_ptr
<
WCondition
>
c
=
(
*
iter
)
->
getChangeCondition
();
if
(
c
.
get
()
)
{
m_changeCondition
->
remove
(
c
);
}
}
m_datasetAccess
->
get
().
clear
();
l
->
get
().
clear
();
m_datasetAccess
->
endWrite
();
// unlock if some callback notified below wants to access the list
l
.
reset
();
m_listChangeCondition
->
notify
();
}
WSubject
::
DatasetSharedContainerType
::
ReadTicket
WSubject
::
getDatasets
()
const
{
return
m_datasets
.
getReadTicket
();
}
std
::
vector
<
boost
::
shared_ptr
<
WDataTexture3D
>
>
WSubject
::
getDataTextures
(
bool
onlyActive
)
{
std
::
vector
<
boost
::
shared_ptr
<
WDataTexture3D
>
>
tex
;
//
iterate the list and find all textures
m_datasetAccess
->
beginRead
();
//
Read lock the list, the lock is freed upon destruction of the ticket (if it goes out of scope for example).
DatasetSharedContainerType
::
ReadTicket
l
=
m_datasets
.
getReadTicket
();
for
(
DatasetContainerType
::
iterator
iter
=
m_datasetAccess
->
get
().
begin
();
iter
!=
m_datasetAccess
->
get
().
end
();
++
iter
)
// iterate the list and find all textures
for
(
DatasetConstIterator
iter
=
l
->
get
().
begin
();
iter
!=
l
->
get
().
end
();
++
iter
)
{
// is it a texture?
if
(
(
*
iter
)
->
isTexture
()
&&
(
!
onlyActive
||
(
*
iter
)
->
getTexture
()
->
isGloballyActive
()
)
)
...
...
@@ -140,12 +147,12 @@ std::vector< boost::shared_ptr< WDataTexture3D > > WSubject::getDataTextures( bo
}
}
m_datasetAccess
->
endRead
();
return
tex
;
}
WSubject
::
DatasetAccess
WSubject
::
getAccessObject
()
{
// TODO(ebaum): clean up if it is not used anymore
return
m_datasets
.
getAccessObject
();
}
...
...
src/dataHandler/WSubject.h
View file @
e306d5b2
...
...
@@ -69,6 +69,16 @@ public:
*/
typedef
WSharedSequenceContainer
<
boost
::
shared_ptr
<
WDataSet
>
,
DatasetContainerType
>
DatasetSharedContainerType
;
/**
* The dataset iterator.
*/
typedef
DatasetContainerType
::
iterator
DatasetIterator
;
/**
* The dataset const iterator.
*/
typedef
DatasetContainerType
::
const_iterator
DatasetConstIterator
;
/**
* Alias for the proper access object
*/
...
...
@@ -124,6 +134,13 @@ public:
*/
void
clear
();
/**
* Returns read-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
*
* \return the read ticket.
*/
DatasetSharedContainerType
::
ReadTicket
getDatasets
()
const
;
/**
* This gives a list of data textures from all supporting datasets in this subject.
*
...
...
@@ -135,6 +152,7 @@ public:
/**
* Gets an access object which allows thread save iteration over the datasets.
*
* \deprecated do not use this anymore. Use getDatasets instead.
* \return the access object.
*/
DatasetAccess
getAccessObject
();
...
...
@@ -160,11 +178,6 @@ protected:
*/
DatasetSharedContainerType
m_datasets
;
/**
* The access object used for thread safe access.
*/
DatasetSharedContainerType
::
WSharedAccess
m_datasetAccess
;
/**
* This condition set fires whenever one dataset gets dirty or the list of datasets changes.
*/
...
...
src/dataHandler/test/WSubject_test.h
View file @
e306d5b2
...
...
@@ -88,20 +88,18 @@ public:
dummyDataSet
->
setFileName
(
fileName
);
WSubject
dummySubject
;
WSubject
::
DatasetAccess
a
=
dummySubject
.
getAccessObject
();
dummySubject
.
addDataSet
(
dummyDataSet
);
TS_ASSERT_EQUALS
(
1
,
dummySubject
.
m_datasets
.
size
()
);
// iterate the list and find all textures
a
->
beginRead
();
WSubject
::
DatasetSharedContainerType
::
ReadTicket
a
=
dummySubject
.
getDatasets
();
int
count
=
0
;
for
(
WSubject
::
DatasetCon
tainerType
::
i
terator
iter
=
a
->
get
().
begin
();
iter
!=
a
->
get
().
end
();
++
iter
)
for
(
WSubject
::
DatasetCon
stI
terator
iter
=
a
->
get
().
begin
();
iter
!=
a
->
get
().
end
();
++
iter
)
{
count
++
;
TS_ASSERT_EQUALS
(
fileName
,
(
*
iter
)
->
getFileName
()
);
TS_ASSERT_EQUALS
(
dummyDataSet
,
(
*
iter
)
);
}
a
->
endRead
();
TS_ASSERT
(
count
==
1
);
}
...
...
src/graphicsEngine/WShader.h
View file @
e306d5b2
...
...
@@ -78,7 +78,7 @@ public:
* defines are a better choice when compared with a lot of branches (if-statements).
*
* \param key The name of the define
* \param value The value of the define. If this is not specified, the define can be used as simple
#
ifdef switch.
* \param value The value of the define. If this is not specified, the define can be used as simple ifdef switch.
*/
void
setDefine
(
std
::
string
key
,
float
value
=
1.0
);
...
...
src/modules/isosurfaceRaytracer/WMIsosurfaceRaytracer.h
View file @
e306d5b2
...
...
@@ -139,13 +139,17 @@ private:
*/
WPropInt
m_alpha
;
/**
* Types of shading supported.
*/
enum
{
Cortex
=
0
,
Depth
,
Phong
,
PhongDepth
}
SHADING_ALGORITHMS
;
}
SHADING_ALGORITHMS
;
/**
* The available shading algorithms.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment