Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
9ab8f66a
Commit
9ab8f66a
authored
8 years ago
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
e32fc562
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
observer.h
dp/observer.h
+7
-7
singleton.h
dp/singleton.h
+4
-0
No files found.
dp/observer.h
View file @
9ab8f66a
...
...
@@ -23,18 +23,18 @@ public:
typedef
std
::
weak_ptr
<
observer_type
>
observer_ptr
;
typedef
std
::
lock_guard
<
std
::
mutex
>
lock_guard_type
;
protected
:
mutable
std
::
mutex
_mutex
;
std
::
list
<
observer_ptr
>
_observers
;
mutable
std
::
mutex
mutex_
;
std
::
list
<
observer_ptr
>
observers_
;
public
:
void
register_observer
(
const
observer_ptr
&
obj
)
{
lock_guard_type
lock
(
_mutex
);
_observers
.
push_back
(
obj
);
lock_guard_type
lock
(
mutex_
);
observers_
.
push_back
(
obj
);
}
void
notify_observers
(
const
target
&
target
)
{
lock_guard_type
lock
(
_mutex
);
auto
iter
=
_observers
.
begin
();
while
(
iter
!=
_observers
.
end
())
{
lock_guard_type
lock
(
mutex_
);
auto
iter
=
observers_
.
begin
();
while
(
iter
!=
observers_
.
end
())
{
std
::
shared_ptr
<
observer_type
>
obj
(
iter
->
lock
());
if
(
obj
)
{
obj
->
on_update
(
target
);
...
...
This diff is collapsed.
Click to expand it.
dp/singleton.h
View file @
9ab8f66a
...
...
@@ -38,6 +38,10 @@ public:
static
void
release_singleton
()
{
instance_
=
nullptr
;
}
static
bool
is_instance_exists
()
{
return
instance_
!=
nullptr
;
}
};
...
...
This diff is collapsed.
Click to expand it.
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