小编Cth*_*lhu的帖子

如何使FFI呼叫中断

根据GHC用户指南,外国电话可以标记interruptible,但是,我无法使其工作.我ghc 8.4.3在GNU/Linux上使用.

例如,参见cbits.h:

/* cbits.h */

void loopForever();
Run Code Online (Sandbox Code Playgroud)

cbits.c:

/* cbits.c */

#include <stdio.h>
#include <unistd.h>

#include "cbits.h"

void loopForever()
{
  for (;;)
  {
    printf("Tick\n");
    sleep(1);
  }
}
Run Code Online (Sandbox Code Playgroud)

最后是Test.hs:

-- Test.hs

{-# LANGUAGE InterruptibleFFI #-}

module Main where

import Control.Concurrent
import Control.Concurrent.Async

main :: IO ()
main = race_ loopForever $ do
  threadDelay 2000000
  putStrLn "Finished"

foreign import ccall interruptible "cbits.h"
  loopForever :: IO ()
Run Code Online (Sandbox Code Playgroud)

我把它全部编成了ghc -threaded -o a.out cbits.c Test.hs.

现在,我预计 …

haskell interrupt ffi ghc

5
推荐指数
0
解决办法
115
查看次数

String to Array和Back

我有一个字符串,如何将其转换为数组?

操作该数组后,如何再次将其变为字符串?

PHP中的字符串是否与Java中的字符串相同?

这有什么骗局?

php arrays string

0
推荐指数
2
解决办法
4399
查看次数

标签 统计

arrays ×1

ffi ×1

ghc ×1

haskell ×1

interrupt ×1

php ×1

string ×1