Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
lvzhengyang
git2
Commits
fabd4771
Commit
fabd4771
authored
Jun 20, 2016
by
Patrick Steinhardt
Committed by
Carlos Martín Nieto
Oct 01, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
threads: split up OS-dependent thread-condition code
parent
1b825316
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
20 deletions
+17
-20
src/thread-utils.h
+0
-7
src/unix/pthread.h
+8
-0
src/win32/pthread.c
+4
-8
src/win32/pthread.h
+5
-5
No files found.
src/thread-utils.h
View file @
fabd4771
...
...
@@ -46,13 +46,6 @@ typedef git_atomic git_atomic_ssize;
# include "unix/pthread.h"
#endif
/* Pthreads condition vars */
#define git_cond pthread_cond_t
#define git_cond_init(c) pthread_cond_init(c, NULL)
#define git_cond_free(c) pthread_cond_destroy(c)
#define git_cond_wait(c, l) pthread_cond_wait(c, l)
#define git_cond_signal(c) pthread_cond_signal(c)
/* Pthread (-ish) rwlock
*
* This differs from normal pthreads rwlocks in two ways:
...
...
src/unix/pthread.h
View file @
fabd4771
...
...
@@ -24,4 +24,12 @@ typedef struct {
#define git_mutex_unlock(a) pthread_mutex_unlock(a)
#define git_mutex_free(a) pthread_mutex_destroy(a)
/* Git condition vars */
#define git_cond pthread_cond_t
#define git_cond_init(c) pthread_cond_init(c, NULL)
#define git_cond_free(c) pthread_cond_destroy(c)
#define git_cond_wait(c, l) pthread_cond_wait(c, l)
#define git_cond_signal(c) pthread_cond_signal(c)
#define git_cond_broadcast(c) pthread_cond_broadcast(c)
#endif
/* INCLUDE_unix_pthread_h__ */
src/win32/pthread.c
View file @
fabd4771
...
...
@@ -91,12 +91,8 @@ int git_mutex_unlock(git_mutex *mutex)
return
0
;
}
int
pthread_cond_init
(
pthread_cond_t
*
cond
,
const
pthread_condattr_t
*
attr
)
int
git_cond_init
(
git_cond
*
cond
)
{
/* We don't support non-default attributes. */
if
(
attr
)
return
EINVAL
;
/* This is an auto-reset event. */
*
cond
=
CreateEventW
(
NULL
,
FALSE
,
FALSE
,
NULL
);
assert
(
*
cond
);
...
...
@@ -106,7 +102,7 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
return
*
cond
?
0
:
ENOMEM
;
}
int
pthread_cond_destroy
(
pthread_cond_t
*
cond
)
int
git_cond_free
(
git_cond
*
cond
)
{
BOOL
closed
;
...
...
@@ -121,7 +117,7 @@ int pthread_cond_destroy(pthread_cond_t *cond)
return
0
;
}
int
pthread_cond_wait
(
pthread_cond_t
*
cond
,
git_mutex
*
mutex
)
int
git_cond_wait
(
git_cond
*
cond
,
git_mutex
*
mutex
)
{
int
error
;
DWORD
wait_result
;
...
...
@@ -142,7 +138,7 @@ int pthread_cond_wait(pthread_cond_t *cond, git_mutex *mutex)
return
git_mutex_lock
(
mutex
);
}
int
pthread_cond_signal
(
pthread_cond_t
*
cond
)
int
git_cond_signal
(
git_cond
*
cond
)
{
BOOL
signaled
;
...
...
src/win32/pthread.h
View file @
fabd4771
...
...
@@ -29,7 +29,7 @@ typedef int pthread_attr_t;
typedef
int
pthread_rwlockattr_t
;
typedef
CRITICAL_SECTION
git_mutex
;
typedef
HANDLE
pthread_cond_t
;
typedef
HANDLE
git_cond
;
typedef
struct
{
void
*
Ptr
;
}
GIT_SRWLOCK
;
...
...
@@ -52,10 +52,10 @@ int git_mutex_free(git_mutex *);
int
git_mutex_lock
(
git_mutex
*
);
int
git_mutex_unlock
(
git_mutex
*
);
int
pthread_cond_init
(
pthread_cond_t
*
,
const
pthread_condattr_t
*
);
int
pthread_cond_destroy
(
pthread_cond_t
*
);
int
pthread_cond_wait
(
pthread_cond_t
*
,
git_mutex
*
);
int
pthread_cond_signal
(
pthread_cond_t
*
);
int
git_cond_init
(
git_cond
*
);
int
git_cond_free
(
git_cond
*
);
int
git_cond_wait
(
git_cond
*
,
git_mutex
*
);
int
git_cond_signal
(
git_cond
*
);
int
pthread_num_processors_np
(
void
);
...
...
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