Example #1
0
    void process()
    {
        CMessageBuffer msg;
        unsigned inputs = container.getInputs();
        unsigned slaves = container.queryJob().querySlaves();
        unsigned s;
        bool readSome=false, slaveReadSome;

        IntArray replyTags;
        for (s=0; s<slaves; s++)
            replyTags.append(0);
        while (inputs>1)
        {
            inputs--;
            for (s=0; s<slaves; s++)
            {
                rank_t sender;
                if (!receiveMsg(msg, RANK_ALL, replyTag, &sender)) return;

                replyTags.replace(msg.getReplyTag(), ((int)sender)-1);
                msg.read(slaveReadSome);
                if (slaveReadSome) readSome = true;
            }
            msg.clear().append(readSome);
            for (s=0; s<slaves; s++)
            {
                if (!queryJobChannel().queryJobComm().send(msg, ((rank_t) s+1), (mptag_t) replyTags.item(s), LONGTIMEOUT))
                    throw MakeActivityException(this, 0, "Failed to give result to slave");
            }
            if (readSome) // got some, have told slaves to ignore rest, so finish
                break;
        }
    }
Example #2
0
void BlockDef::createFace(World * world, Position & camPosition, Vector3d pos, Dir face, FloatArray & vertices, IntArray & indexes) {
	int v0 = vertices.length() / VERTEX_COMPONENTS;
	float * vptr = vertices.append(0.0f, VERTEX_COMPONENTS * 4);
	int * iptr = indexes.append(0, 6);
	createFaceMesh(vptr, face, pos.x + 0.5f, pos.y + 0.5f, pos.z + 0.5f, txIndex);
	for (int i = 0; i < 6; i++)
		iptr[i] = v0 + face_indexes[i];
	if (HIGHLIGHT_GRID && ((pos.x & 7) == 0 || (pos.z & 7) == 0)) {
		for (int i = 0; i < 4; i++) {
			vptr[11 * i + 6 + 0] = 1.4f;
			vptr[11 * i + 6 + 1] = 1.4f;
			vptr[11 * i + 6 + 2] = 1.4f;
		}
	}
}