Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-astreamer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-apps-astreamer
Commits
09d720de
Commit
09d720de
authored
Feb 21, 2017
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: go back to C++98 and use classic arrays instread of std::array
parent
1503550d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
main.cpp
src/main.cpp
+10
-12
No files found.
src/main.cpp
View file @
09d720de
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include <iostream>
#include <iostream>
#include <string>
#include <string>
#include <map>
#include <map>
#include <array>
#include "streamer.h"
#include "streamer.h"
...
@@ -38,16 +37,16 @@ using namespace std;
...
@@ -38,16 +37,16 @@ using namespace std;
* @param threads an array of thread pointers
* @param threads an array of thread pointers
* @return None
* @return None
*/
*/
void
clean_up
(
array
<
pthread_t
,
SENSOR_PORTS
>
&
threads
)
{
void
clean_up
(
pthread_t
*
threads
,
size_t
sz
)
{
for
(
array
<
pthread_t
,
SENSOR_PORTS
>::
iterator
it
=
threads
.
begin
();
it
!=
threads
.
end
();
it
++
)
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
pthread_cancel
(
*
it
);
pthread_cancel
(
threads
[
i
]
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
string
opt
;
string
opt
;
map
<
string
,
string
>
args
;
map
<
string
,
string
>
args
;
array
<
pthread_t
,
SENSOR_PORTS
>
threads
;
pthread_t
threads
[
SENSOR_PORTS
]
;
array
<
Streamer
*
,
SENSOR_PORTS
>
streamers
;
Streamer
*
streamers
[
SENSOR_PORTS
]
=
{
NULL
}
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
argv
[
i
][
0
]
==
'-'
&&
argv
[
i
][
1
]
!=
'\0'
)
{
if
(
argv
[
i
][
0
]
==
'-'
&&
argv
[
i
][
1
]
!=
'\0'
)
{
...
@@ -70,19 +69,18 @@ int main(int argc, char *argv[]) {
...
@@ -70,19 +69,18 @@ int main(int argc, char *argv[]) {
for
(
int
i
=
0
;
i
<
SENSOR_PORTS
;
i
++
)
{
for
(
int
i
=
0
;
i
<
SENSOR_PORTS
;
i
++
)
{
pthread_attr_t
attr
;
pthread_attr_t
attr
;
streamers
[
i
]
=
new
Streamer
(
args
);
streamers
[
i
]
=
new
Streamer
(
args
,
i
);
pthread_attr_init
(
&
attr
);
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
if
(
!
pthread_create
(
&
threads
[
i
],
&
attr
,
Streamer
::
pthread_f
,
(
void
*
)
streamers
[
i
]))
{
if
(
!
pthread_create
(
&
threads
[
i
],
&
attr
,
Streamer
::
pthread_f
,
(
void
*
)
streamers
[
i
]))
{
cerr
<<
"Can not spawn streamer thread for port "
<<
to_string
(
i
)
<<
endl
;
cerr
<<
"Can not spawn streamer thread for port "
<<
i
<<
endl
;
clean_up
(
threads
);
clean_up
(
threads
,
SENSOR_PORTS
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
pthread_attr_destroy
(
&
attr
);
pthread_attr_destroy
(
&
attr
);
}
}
for
(
array
<
pthread_t
,
SENSOR_PORTS
>::
iterator
it
=
threads
.
begin
();
it
!=
threads
.
end
();
it
++
)
for
(
size_t
i
=
0
;
i
<
SENSOR_PORTS
;
i
++
)
pthread_join
(
*
it
,
NULL
);
pthread_join
(
threads
[
i
]
,
NULL
);
return
0
;
return
0
;
}
}
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