Skip to content
This repository was archived by the owner on Oct 2, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a2a0513
[pull/stream] start again
tmpvar Oct 3, 2020
f11ef36
[pull/stream] basically back to parity with the sync primitives from …
tmpvar Oct 4, 2020
277a940
[pull/stream] taker can be told to either ERR or DONE when it takes t…
tmpvar Oct 4, 2020
8347bff
[pull/stream/sync] add hex-printer and single-value streams
tmpvar Oct 4, 2020
6ff0e56
[pull/stream] rename PS_CB_FIELDS to PS_FIELDS
tmpvar Oct 4, 2020
3c08a5c
[pull/stream] fix build on linux
tmpvar Oct 4, 2020
82ad5d9
[pull/stream] remove debug in hex-printer test and add some new lines…
tmpvar Oct 4, 2020
a030557
[pull/stream] minor tweaks
tmpvar Oct 4, 2020
b3a8069
[pull/stream/io] add source-file
tmpvar Oct 4, 2020
5461f4a
[pull/stream/io] port sink-file
tmpvar Oct 4, 2020
01f522c
[pull/stream] begin work on duplex/tcp streams
tmpvar Oct 5, 2020
b2822db
[pull/stream] all primitives are based on a handle base type
tmpvar Oct 5, 2020
ed89850
[pull/stream] rename handle_status / pull_through
tmpvar Oct 5, 2020
f672e78
[pull/stream] ps_status now handles all handle types
tmpvar Oct 5, 2020
dd84fc3
[pull/stream] all values are created via ps_create_value
tmpvar Oct 5, 2020
e5f1249
[pull/stream] first round duplex tcp client implemntation and shared …
tmpvar Oct 5, 2020
7e958e7
[pull/stream] fix error on linux
tmpvar Oct 5, 2020
d04f7e2
[pull/stream] add tcp server
tmpvar Oct 6, 2020
44eab3c
[pull/stream] add a byte reverser stream
tmpvar Oct 7, 2020
4e61f8f
[pull/stream] add `splitter` through stream
tmpvar Oct 7, 2020
363f608
[pull/stream/io] fix warning on windows in duplex tcp test
tmpvar Oct 7, 2020
d03f656
[pull/stream] add user value source stream
tmpvar Oct 7, 2020
a4c9297
[pull/stream] add more tests around splitter
tmpvar Oct 7, 2020
3ba6bd9
[pull/stream] add ps_pipeline to reduce the cognitive overhead of bui…
tmpvar Oct 7, 2020
1d9e53d
[pull/stream] start on a README
tmpvar Oct 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ before_install:
brew install llvm@10
cmake .. || cat C:/Users/travis/build/tmpvar/rawkit/build/CMakeFiles/CMakeOutput.log
fi
- pip3 install --user cpp-coveralls
install: pip3 install --user --upgrade pip
install:
- pip3 install cpp-coveralls
script:
- cmake --build . --config Debug --target rawkit-test && ctest -C Debug
after_success:
- coveralls -r .. -i "lib/" -b $(pwd) --gcov-options '\-lp' --exclude-pattern "CMake.*" --exclude-pattern '.*test.*' --exclude include -E "CMakeFiles" -E build/CMakeFiles -E 'test.*.cpp' --exclude lib/test --exclude src --exclude projects --verbose
- cpp-coveralls -r .. -i "lib/" -b $(pwd) --gcov-options '\-lp' --exclude-pattern "CMake.*" --exclude-pattern '.*test.*' --exclude include -E "CMakeFiles" -E build/CMakeFiles -E 'test.*.cpp' --exclude lib/test --exclude src --exclude projects --verbose
#- coveralls -r lib --gcov $(which llvm-cov) --gcov-options '\-lp'
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ include_directories(
${DEPS_DIR}/whereami/src
)

# DEP: pull-stream
set(PULL_STREAM_BUILD_TESTS OFF CACHE INTERNAL "")
set(PULL_STREAM_TEST_COVERAGE ON CACHE INTERNAL "")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/lib/pull-stream)
include_directories(
${CMAKE_CURRENT_LIST_DIR}/lib/pull-stream/include
)

# DEP: gcode-parser
set(RAWKIT_GCODE_PARSER_BUILD_TESTS OFF CACHE INTERNAL "")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/lib/gcode-parser)
Expand Down Expand Up @@ -321,6 +329,7 @@ enable_testing()
set(RAWKIT_TEST_FILES
${RAWKIT_GCODE_PARSER_TEST_FILES}
${RAWKIT_GRBL_PARSER_TEST_FILES}
${PULL_STREAM_TEST_FILES}
)

add_executable(rawkit-test
Expand All @@ -329,6 +338,7 @@ add_executable(rawkit-test
)

set_property(TARGET rawkit-test PROPERTY CXX_STANDARD 11)
set_property(TARGET rawkit-test PROPERTY C_STANDARD 11)

source_group("tests" FILES ${RAWKIT_TEST_FILES})

Expand All @@ -351,6 +361,10 @@ else()
)
endif()

target_link_libraries(rawkit-test PRIVATE
pull-stream
)

target_compile_options(rawkit-test PRIVATE
${RAWKIT_TEST_COMPILE_FLAGS}
)
Expand Down
108 changes: 108 additions & 0 deletions lib/pull-stream/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
cmake_minimum_required(VERSION 3.14)
project(pull-stream)


option(PULL_STREAM_BUILD_TESTS "Build the pull-stream test programs" ON)
option(PULL_STREAM_TEST_COVERAGE "Add coverage information for tests run against libpull_stream" OFF)

include_directories(include)

# DEP: libuv
add_subdirectory(
${CMAKE_CURRENT_LIST_DIR}/deps/libuv-1.39.0
)
set(LIBUV_LIBS uv_a ${uv_libraries} CACHE INTERNAL "")
set(LIBUV_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/deps/libuv-1.39.0/include CACHE INTERNAL "")
include_directories(${LIBUV_INCLUDE_DIRS})

file(GLOB PULL_STREAM_CORE_SOURCES
"${CMAKE_CURRENT_LIST_DIR}/src/core/*.c"
)

file(GLOB PULL_STREAM_IO_SOURCES
"${CMAKE_CURRENT_LIST_DIR}/src/io/*.c"
)

file(GLOB PULL_STREAM_SYNC_SOURCES
"${CMAKE_CURRENT_LIST_DIR}/src/sync/*.c"
)

add_library(pull-stream
${PULL_STREAM_CORE_SOURCES}
${PULL_STREAM_IO_SOURCES}
${PULL_STREAM_SYNC_SOURCES}
)

source_group("core" FILES ${PS_CORE_SOURCES})
source_group("io" FILES ${PS_IO_SOURCES})
source_group("sync" FILES ${PS_PRIMITIVE_SOURCES})

set_property(TARGET pull-stream PROPERTY CXX_STANDARD 11)
set_property(TARGET pull-stream PROPERTY C_STANDARD 11)

include_directories(
${CMAKE_CURRENT_LIST_DIR}/include
)

target_include_directories(pull-stream PRIVATE
${CMAKE_CURRENT_LIST_DIR}/deps/croaring
)

target_link_libraries(pull-stream PUBLIC uv_a)

if (PULL_STREAM_TEST_COVERAGE)
target_compile_options(pull-stream PUBLIC
-g
-O0
--coverage
-ftest-coverage
-fprofile-arcs
-fno-default-inline
-fno-inline
)
endif()

# Testing
file(GLOB PULL_STREAM_TEST_FILES
"${CMAKE_CURRENT_LIST_DIR}/test/*-test.cpp"
)
set(PULL_STREAM_TEST_FILES ${PULL_STREAM_TEST_FILES} CACHE INTERNAL "")

if (PULL_STREAM_BUILD_TESTS)
target_link_options(pull-stream PUBLIC
--coverage
)

# DEP: doctest
include_directories(
${CMAKE_CURRENT_LIST_DIR}/deps/doctest
)

include(CTest)
enable_testing()

add_executable(pull-stream-test
${CMAKE_CURRENT_LIST_DIR}/test/test.cpp
${PULL_STREAM_TEST_FILES}
)

set_property(TARGET pull-stream-test PROPERTY CXX_STANDARD 11)
set_property(TARGET pull-stream-test PROPERTY C_STANDARD 11)


source_group("tests" FILES ${PULL_STREAM_TEST_FILES})

target_compile_options(pull-stream-test PRIVATE
-Wall
)

target_link_libraries(pull-stream-test PRIVATE
pull-stream
)

target_include_directories(pull-stream-test PRIVATE
${CMAKE_CURRENT_LIST_DIR}/deps/doctest
)

add_test(pull-stream pull-stream-test)
endif()
8 changes: 8 additions & 0 deletions lib/pull-stream/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright © 2020 Elijah Insua <tmpvar@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 changes: 40 additions & 0 deletions lib/pull-stream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# pull-stream

A C99 / >= C++10 interpretation of the JS [pull-stream](https://pull-stream.github.io/)
ecosystem. This is meant to be used primarily with [rawkit](https://github.com/tmpvar/rawkit),
but maybe it has utility elsewhere.

## rules

There are a few rules that pull streams should follow:

1. Data only flows when you pull.
2. Values returned by a pull are `ps_destroy`able
3. Marking the status of a stream to `PS_ERR` should release and pending data and abort.
4. Marking the status of a stream to `PS_DONE` may continue dequeuing pending data.
5. `NULL` returned by a pull means nothing more than the source stream did not have data to return.

## usage

```c
#include <pull/stream.h>
#include <stdio.h>

int main() {
ps_t *s = ps_pipeline(
// emit a single value "hello"
create_single_value((void *)"hello", 5),

// bytewise reverse (at the packet level)
create_reverser(),

// take one packet and then mark the pipeline as PS_DONE
create_taker(1, PS_DONE)
);

// pull from s, which is actually the sink defined w/ `create_taker`
ps_val_t *val = s->fn(s, PS_OK);

printf("RESULT: %s\n", (char *)val->data);
}
```
Loading