Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ThreadId
- data Chan (t :: k) (a :: k1) :: forall k k1. k -> k1 -> Type
- data Closeable
- data Uncloseable
- class Transferable a where
- type SizeSpec a :: *
- calcChanSize :: proxy a -> SizeSpec a -> ChanSize Data PrimType' Length
- newChan :: SizeSpec a -> Run (Chan Uncloseable a)
- newCloseableChan :: SizeSpec a -> Run (Chan Closeable a)
- readChan :: Chan t a -> Run a
- untypedReadChan :: Chan t c -> Run a
- writeChan :: Chan t a -> a -> Run (Data Bool)
- untypedWriteChan :: Chan t c -> a -> Run (Data Bool)
- class Transferable a => BulkTransferable a where
- type ContainerType a :: *
- readChanBuf :: Chan t a -> Data Index -> Data Index -> ContainerType a -> Run (Data Bool)
- untypedReadChanBuf :: proxy a -> Chan t c -> Data Index -> Data Index -> ContainerType a -> Run (Data Bool)
- writeChanBuf :: Chan t a -> Data Index -> Data Index -> ContainerType a -> Run (Data Bool)
- untypedWriteChanBuf :: proxy a -> Chan t c -> Data Index -> Data Index -> ContainerType a -> Run (Data Bool)
- fork :: Run () -> Run ThreadId
- forkWithId :: (ThreadId -> Run ()) -> Run ThreadId
- asyncKillThread :: ThreadId -> Run ()
- killThread :: ThreadId -> Run ()
- waitThread :: ThreadId -> Run ()
- delayThread :: Integral i => Data i -> Run ()
- closeChan :: Chan Closeable a -> Run ()
- lastChanReadOK :: Chan Closeable a -> Run (Data Bool)
Documentation
data Uncloseable #
class Transferable a where Source #
Size specification of a channel. In most of the cases, it is a natural number representing how many elements could be stored at the same time in the channel.
calcChanSize :: proxy a -> SizeSpec a -> ChanSize Data PrimType' Length Source #
Maps a size specification to an internal channel size representation, that is a map from primitive types to quantities. The byte size of the channel will be calculated as the sum of multiplying the byte size of each type with its quantity.
newChan :: SizeSpec a -> Run (Chan Uncloseable a) Source #
Create a new channel. Writing a reference type to a channel will copy contents into the channel, so modifying it post-write is completely safe.
newCloseableChan :: SizeSpec a -> Run (Chan Closeable a) Source #
readChan :: Chan t a -> Run a Source #
Read an element from a channel. If channel is empty, blocks until there
is an item available.
If closeChan
has been called on the channel *and* if the channel is
empty, readChan
returns an undefined value immediately.
untypedReadChan :: Chan t c -> Run a Source #
Reads a value from any kind of channel. Instances should define this, but the user should never call it.
writeChan :: Chan t a -> a -> Run (Data Bool) Source #
Write a data element to a channel.
If closeChan
has been called on the channel, all calls to writeChan
become non-blocking no-ops and return False
, otherwise returns True
.
If the channel is full, this function blocks until there's space in the
queue.
untypedWriteChan :: Chan t c -> a -> Run (Data Bool) Source #
Writes a value to any kind of channel. Instances should define this, but the user should never call it.
Instances
class Transferable a => BulkTransferable a where Source #
type ContainerType a :: * Source #
:: Chan t a | |
-> Data Index | Offset in array to start writing |
-> Data Index | Elements to read |
-> ContainerType a | |
-> Run (Data Bool) |
Read an arbitrary number of elements from a channel into an array.
The semantics are the same as for readChan
, where "channel is empty"
is defined as "channel contains less data than requested".
Returns False
without reading any data if the channel is closed.
:: proxy a | |
-> Chan t c | |
-> Data Index | Offset in array to start writing |
-> Data Index | Elements to read |
-> ContainerType a | |
-> Run (Data Bool) |
Read an arbitrary number of elements from any channel into an array. Instances should define this, but the user should never call it.
:: Chan t a | |
-> Data Index | Offset in array to start reading |
-> Data Index | Elements to write |
-> ContainerType a | |
-> Run (Data Bool) |
Write an arbitrary number of elements from an array into an channel.
The semantics are the same as for writeChan
, where "channel is full"
is defined as "channel has insufficient free space to store all written
data".
:: proxy a | |
-> Chan t c | |
-> Data Index | Offset in array to start reading |
-> Data Index | Elements to write |
-> ContainerType a | |
-> Run (Data Bool) |
Write an arbitrary number of elements from an array into any channel. Instances should define this, but the user should never call it.
Instances
PrimType' a => BulkTransferable (Data a) Source # | |
Defined in Feldspar.Run.Concurrent type ContainerType (Data a) :: Type Source # readChanBuf :: Chan t (Data a) -> Data Index -> Data Index -> ContainerType (Data a) -> Run (Data Bool) Source # untypedReadChanBuf :: proxy (Data a) -> Chan t c -> Data Index -> Data Index -> ContainerType (Data a) -> Run (Data Bool) Source # writeChanBuf :: Chan t (Data a) -> Data Index -> Data Index -> ContainerType (Data a) -> Run (Data Bool) Source # untypedWriteChanBuf :: proxy (Data a) -> Chan t c -> Data Index -> Data Index -> ContainerType (Data a) -> Run (Data Bool) Source # |
forkWithId :: (ThreadId -> Run ()) -> Run ThreadId Source #
Fork off a computation as a new thread, with access to its own thread ID.
asyncKillThread :: ThreadId -> Run () Source #
Forcibly terminate a thread, then continue execution immediately.
killThread :: ThreadId -> Run () Source #
Forcibly terminate a thread. Blocks until the thread is actually dead.
waitThread :: ThreadId -> Run () Source #
Wait for a thread to terminate.
delayThread :: Integral i => Data i -> Run () Source #
Sleep for a given amount of microseconds. Implemented with usleep
.
A C compiler might require a feature test macro to be defined,
otherwise it emits a warning about an implicitly declared function.
For more details, see: http://man7.org/linux/man-pages/man3/usleep.3.html