Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
52e810ed
Commit
52e810ed
authored
Nov 25, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Nov 25, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1850 from ilya-lavrenov:pthread_mutex
parents
3ab47300
c8abb612
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
38 deletions
+15
-38
system.cpp
modules/core/src/system.cpp
+15
-38
No files found.
modules/core/src/system.cpp
View file @
52e810ed
...
...
@@ -748,50 +748,27 @@ struct Mutex::Impl
int
refcount
;
};
#elif defined __APPLE__
#include <libkern/OSAtomic.h>
struct
Mutex
::
Impl
{
Impl
()
{
sl
=
OS_SPINLOCK_INIT
;
refcount
=
1
;
}
~
Impl
()
{}
void
lock
()
{
OSSpinLockLock
(
&
sl
);
}
bool
trylock
()
{
return
OSSpinLockTry
(
&
sl
);
}
void
unlock
()
{
OSSpinLockUnlock
(
&
sl
);
}
OSSpinLock
sl
;
int
refcount
;
};
#elif defined __linux__ && !defined ANDROID
struct
Mutex
::
Impl
{
Impl
()
{
pthread_spin_init
(
&
sl
,
0
);
refcount
=
1
;
}
~
Impl
()
{
pthread_spin_destroy
(
&
sl
);
}
void
lock
()
{
pthread_spin_lock
(
&
sl
);
}
bool
trylock
()
{
return
pthread_spin_trylock
(
&
sl
)
==
0
;
}
void
unlock
()
{
pthread_spin_unlock
(
&
sl
);
}
pthread_spinlock_t
sl
;
int
refcount
;
};
#else
struct
Mutex
::
Impl
{
Impl
()
{
pthread_mutex_init
(
&
sl
,
0
);
refcount
=
1
;
}
~
Impl
()
{
pthread_mutex_destroy
(
&
sl
);
}
Impl
()
{
pthread_mutexattr_t
attr
;
pthread_mutexattr_init
(
&
attr
);
pthread_mutexattr_settype
(
&
attr
,
PTHREAD_MUTEX_RECURSIVE
);
pthread_mutex_init
(
&
mt
,
&
attr
);
pthread_mutexattr_destroy
(
&
attr
);
refcount
=
1
;
}
~
Impl
()
{
pthread_mutex_destroy
(
&
mt
);
}
void
lock
()
{
pthread_mutex_lock
(
&
sl
);
}
bool
trylock
()
{
return
pthread_mutex_trylock
(
&
sl
)
==
0
;
}
void
unlock
()
{
pthread_mutex_unlock
(
&
sl
);
}
void
lock
()
{
pthread_mutex_lock
(
&
mt
);
}
bool
trylock
()
{
return
pthread_mutex_trylock
(
&
mt
)
==
0
;
}
void
unlock
()
{
pthread_mutex_unlock
(
&
mt
);
}
pthread_mutex_t
sl
;
pthread_mutex_t
mt
;
int
refcount
;
};
...
...
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