Пример #1
0
/* this example was meant to be  brief, so we've omitted checks for
 * Message Board routines' return code.
 * In practice, you would want to check all return code, and handle any
 * erroneous conditions
 */
int main(int argc, char **argv) {

    int rc;
    void *msg;
    int id, pcount;
    MBt_Board mboard;
    MBt_Iterator iter;
    double mypi, pi, sum, h;

    /* Initialise Message Board environment */
    MB_Env_Init();

    /* get my ID and proc count */
    id = MB_Env_GetProcID();
    pcount = MB_Env_GetProcCount();

    /* Create a board that can store doubles */
    MB_Create(&mboard, sizeof(double));

    /* calculate my portion of pi */
    h = 1.0 / (double)NR;
    pi = sum = 0.0;
    for (i = id + 1; i <= NR; i += pcount)
    {
        sum += FUNC_X(((double)i - 0.5)*h);
    }

    /* Everyone adds their sum to the board */
    MB_AddMessage(mboard, &sum);

    /* Synchornise boards */
    /* If there are more things to do that does not involved the board
     * we can run them between SyncStart() and SyncComplete(). That will
     * overlap the communication time with your own computation.
     */
    MB_SyncStart(mboard);
    MB_SyncComplete(mboard);

    /* Master node reads message and prints out result */
    if (id == 0)
    {
        MB_Iterator_Create(mboard, &iter);
        MB_Iterator_GetMessage(iter, msg);
        while (msg)
        {
            pi += *((double *)msg);
            MB_Iterator_GetMessage(iter, msg);
        }
        MB_Iterator_Delete(&iter);

        printf("Pi is approximately %.16f\n", pi);
    }

    /* Delete board */
    MB_Delete(&mboard);

    /* Finalise Message Board environment */
    return MB_Env_Finalise();
}
Пример #2
0
void WINAPI GetPluginInfoWcmn(void *piv)
{
	if (gFarVersion.dwBuild>=FAR_Y2_VER)
		FUNC_Y2(GetPluginInfoW)(piv);
	else if (gFarVersion.dwBuild>=FAR_Y1_VER)
		FUNC_Y1(GetPluginInfoW)(piv);
	else
		FUNC_X(GetPluginInfoW)(piv);
}
Пример #3
0
int WINAPI ConfigureW3(void*)
{
	if (gFarVersion.dwVerMajor==1)
		return false;
	else if (gFarVersion.dwBuild>=FAR_Y2_VER)
		return FUNC_Y2(ConfigureW)(0);
	else if (gFarVersion.dwBuild>=FAR_Y1_VER)
		return FUNC_Y1(ConfigureW)(0);
	else
		return FUNC_X(ConfigureW)(0);
}
Пример #4
0
int WINAPI ConfigureW(int ItemNumber)
{
	if (gFarVersion.dwVerMajor==1)
		return false;
	else if (gFarVersion.dwBuild>=FAR_Y2_VER)
		return FUNC_Y2(ConfigureW)(ItemNumber);
	else if (gFarVersion.dwBuild>=FAR_Y1_VER)
		return FUNC_Y1(ConfigureW)(ItemNumber);
	else
		return FUNC_X(ConfigureW)(ItemNumber);
}
Пример #5
0
LPCWSTR GetMsgW(int aiMsg)
{
	if (gFarVersion.dwVerMajor==1)
		return L"";
	else if (gFarVersion.dwBuild>=FAR_Y2_VER)
		return FUNC_Y2(GetMsgW)(aiMsg);
	else if (gFarVersion.dwBuild>=FAR_Y1_VER)
		return FUNC_Y1(GetMsgW)(aiMsg);
	else
		return FUNC_X(GetMsgW)(aiMsg);
}
Пример #6
0
void WINAPI ExitFARW3(void*)
{
	ExitPlugin();

	if (gFarVersion.dwBuild>=FAR_Y2_VER)
		FUNC_Y2(ExitFARW)();
	else if (gFarVersion.dwBuild>=FAR_Y1_VER)
		FUNC_Y1(ExitFARW)();
	else
		FUNC_X(ExitFARW)();
}
Пример #7
0
void SettingsSave()
{
	if (gFarVersion.dwVerMajor == 1)
		SettingsSaveA();
	else if (gFarVersion.dwBuild >= FAR_Y2_VER)
		FUNC_Y2(SettingsSaveW)();
	else if (gFarVersion.dwBuild >= FAR_Y1_VER)
		FUNC_Y1(SettingsSaveW)();
	else
		FUNC_X(SettingsSaveW)();
}
Пример #8
0
void WINAPI SetStartupInfoW(void *aInfo)
{
	gbSetStartupInfoOk = true;

	if (!gFarVersion.dwVerMajor) LoadFarVersion();

	if (gFarVersion.dwBuild>=FAR_Y2_VER)
		FUNC_Y2(SetStartupInfoW)(aInfo);
	else if (gFarVersion.dwBuild>=FAR_Y1_VER)
		FUNC_Y1(SetStartupInfoW)(aInfo);
	else
		FUNC_X(SetStartupInfoW)(aInfo);

	//_ASSERTE(gszRootKey!=NULL && *gszRootKey!=0);
	gbInfoW_OK = TRUE;
	StartPlugin(FALSE);
}
Пример #9
0
void SettingsLoad()
{
	if (!gbSetStartupInfoOk)
	{
		_ASSERTE(gbSetStartupInfoOk);
		return;
	}

	if (gFarVersion.dwVerMajor == 1)
		SettingsLoadA();
	else if (gFarVersion.dwBuild >= FAR_Y2_VER)
		FUNC_Y2(SettingsLoadW)();
	else if (gFarVersion.dwBuild >= FAR_Y1_VER)
		FUNC_Y1(SettingsLoadW)();
	else
		FUNC_X(SettingsLoadW)();
}