set sockets to close on exec
git-svn-id: svn://anubis/fart/trunk@228 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
68450b8c4d
commit
8424e34a91
4 files changed
+125
-12
No files matched your search
+14
-6
@@ -104,6 +104,12 @@ Scene::Scene(const map<string, const char *> & options,
|
||||
m_distrib.readHostFile(m_hosts_file.c_str());
|
||||
m_distrib.startServer();
|
||||
m_distrib.startClients(m_client_options);
|
||||
|
||||
m_data = new unsigned char[m_width * m_height * 3]; /* 24bpp */
|
||||
int num_tasks = (m_width * m_height + (UNIT_TASK_SIZE - 1))
|
||||
/ UNIT_TASK_SIZE;
|
||||
m_distrib.set_num_tasks(num_tasks);
|
||||
m_distrib.set_data(m_data, 3 * m_width * m_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -140,8 +146,6 @@ void Scene::render()
|
||||
cout << "----------------------------------------" << endl;
|
||||
}
|
||||
|
||||
m_data = new unsigned char[m_width * m_height * 3]; /* 24bpp */
|
||||
|
||||
if (m_distrib.getNumClients() < 1)
|
||||
{
|
||||
for (int i = 0; i < m_height; i++)
|
||||
@@ -154,9 +158,9 @@ void Scene::render()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_distrib.set_data(m_data);
|
||||
/* work on tasks in this thread until there are no more */
|
||||
taskLoop();
|
||||
/* TODO: wait until all data has arrived */
|
||||
}
|
||||
|
||||
if (m_verbose)
|
||||
@@ -176,25 +180,29 @@ void Scene::render()
|
||||
|
||||
void Scene::taskLoop()
|
||||
{
|
||||
unsigned char data[3 * UNIT_TASK_SIZE];
|
||||
for (;;)
|
||||
{
|
||||
int task_id = m_distrib.getTask();
|
||||
if (task_id < 0)
|
||||
break;
|
||||
unsigned char data[3 * UNIT_TASK_SIZE];
|
||||
int i = task_id / m_width;
|
||||
int j = task_id % m_width;
|
||||
for (int t = 0; t < UNIT_TASK_SIZE; t++)
|
||||
{
|
||||
renderPixel(j, i, &data[3 * t]);
|
||||
j++;
|
||||
if (j == m_width)
|
||||
if (j >= m_width)
|
||||
{
|
||||
j = 0;
|
||||
i++;
|
||||
if (i >= m_height)
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_distrib.send_data(task_id, data, 3 * UNIT_TASK_SIZE);
|
||||
int ret = m_distrib.send_data(task_id, data, 3 * UNIT_TASK_SIZE);
|
||||
if (ret != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "Light.h"
|
||||
|
||||
#define SCENE_FACTOR_THRESHOLD 0.02
|
||||
#define UNIT_TASK_SIZE 50
|
||||
|
||||
class Scene
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user