Ignore:
Timestamp:
Mar 21, 2018, 3:21:23 PM (7 years ago)
Author:
bird
Message:

kmk/win: Make outsource the writing part of kmk_builtin_append to a worker thread to try avoid blocking the main kmk thread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/append.c

    r3171 r3172  
    4545#ifdef HAVE_ALLOCA_H
    4646# include <alloca.h>
     47#endif
     48#if !defined(kmk_builtin_append) && defined(KBUILD_OS_WINDOWS) && defined(CONFIG_NEW_WIN_CHILDREN)
     49# include "../w32/winchildren.h"
    4750#endif
    4851#include "err.h"
     
    169172 * Appends text to a textfile, creating the textfile if necessary.
    170173 */
    171 int kmk_builtin_append(int argc, char **argv, char **envp)
     174#ifndef kmk_builtin_append
     175int kmk_builtin_append(int argc, char **argv, char **envp, struct child *pChild, pid_t *pPidSpawned)
     176#else
     177int main(int argc, char **argv, char **envp)
     178#endif
    172179{
     180#if defined(KBUILD_OS_WINDOWS) || defined(KBUILD_OS_OS2)
     181    static const char s_szNewLine[] = "\r\n";
     182#else
     183    static const char s_szNewLine[] = "\n";
     184#endif
     185    KMKBUILTINAPPENDBUF OutBuf = { NULL, 0, 0, 0 };
    173186    const char *pszFilename;
    174187    int rc = 88;
     
    184197    int fLookForInserts = 0;
    185198#endif
    186 #if defined(KBUILD_OS_WINDOWS) || defined(KBUILD_OS_OS2)
    187     static const char s_szNewLine[] = "\r\n";
    188 #else
    189     static const char s_szNewLine[] = "\n";
    190 #endif
    191     KMKBUILTINAPPENDBUF OutBuf = { NULL, 0, 0, 0 };
    192199
    193200    g_progname = argv[0];
     
    409416     * Write the buffer (unless we ran out of heap already).
    410417     */
     418#if !defined(kmk_builtin_append) && defined(KBUILD_OS_WINDOWS) && defined(CONFIG_NEW_WIN_CHILDREN)
     419    if (!OutBuf.fOutOfMemory)
     420    {
     421        rc = MkWinChildCreateAppend(pszFilename, &OutBuf.pszBuf, OutBuf.offBuf, fTruncate, pChild, pPidSpawned);
     422        if (rc != 0)
     423            rc = errx(rc, "MkWinChildCreateAppend failed: %u", rc);
     424        if (OutBuf.pszBuf)
     425            free(OutBuf.pszBuf);
     426    }
     427    else
     428#endif
    411429    if (!OutBuf.fOutOfMemory)
    412430    {
Note: See TracChangeset for help on using the changeset viewer.